Differences between revisions 6 and 7
Revision 6 as of 2007-08-31 19:24:55
Size: 910
Editor: 13
Comment: wxPython documentation link
Revision 7 as of 2007-08-31 21:51:28
Size: 1461
Editor: PaulBoddie
Comment: Tidy up recent and previous additions.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from 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?
I don't kn
ow ;) but entering the command:
= 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 foll
ows...
Line 6: Line 9:
into the Python interpreter gives a list of defined classes and variables. ...gives a list of defined classes and variables.
Line 8: Line 11:
Using the TAB key on one of the existing objects opens a list of possible completions, i.e. its methods/attributes. 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 ==
Line 12: Line 19:
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
Line 14: Line 23:
= wxPython =
There ''is'', however, such documentation for wxPython (a GUI-building kit for Python), although it is still under development. [http://www.wxpython.org/docs/api/ Here is the link].
== API Documentation ==

The DocumentationTools page provides details of tools which can produce API documentation for Python applications and libraries, such as that provided for [wiki:WxPython wxPython] (a GUI-building kit for Python): [http://www.wxpython.org/docs/api/ wxPython API documentation].

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 [wiki:WxPython wxPython] (a GUI-building kit for Python): [http://www.wxpython.org/docs/api/ wxPython API documentation].

Asking for Help/Can Python introspect like Java? (last edited 2011-03-26 23:23:03 by PaulBoddie)

Unable to edit the page? See the FrontPage for instructions.