This is a static archive of the Python wiki, which was retired in February 2026 due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

Can Python Introspect Like Java?

"I come from a java background. Java has an API that list all classes and their methods that come with Java. Is there anything like that in python?"

At the Python interpreter prompt, invoking the dir function as follows...

>>> dir()

...gives a list of defined classes and variables.

In certain interactive shells (or prompts), such as IPython, using the TAB key on one of the existing objects opens a list of possible completions, i.e. its methods/attributes. For other plainer shells, you can call the dir function supplying an object as an argument to see the contents of that object:

>>> dir(some_object)

Discussion

I'm not sure this is what the OP is asking. I think s/he's referring to the API documentation rather than the API itself. Calling help(object) in the interpreter is a good start for help on an object.

In fact, the dir and help built-in functions make use of Python's introspection capabilities. Another interface can be found in the standard library inspect module. -- PaulBoddie

CL's answer: no, Python cannot introspect like Java; it can only do better.

API Documentation

The DocumentationTools page provides details of tools which can produce API documentation for Python applications and libraries, such as that provided for wxPython (a GUI-building kit for Python): wxPython API documentation.


CategoryAskingForHelp CategoryAskingForHelpAnswered


2026-02-14 16:06