[geeks] quick python question

Dave Kimmel crisco_kid at shaw.ca
Wed Jun 26 00:27:33 CDT 2002


On Tue, 25 Jun 2002, Joshua D Boyd wrote:

> I've heard that python supports introspection.
>
> So, does anyone know how to ask a class what it's methods and/or
> properties are?

I believe that you're looking for the dir() function.  That'll list all of
the properties and methods of any object.  Then you can do dir() on each
one and see what kind of stuff it has - ie, if it has __call__ its a
method, etc.

I've found it quite helpful in the interactive Python shell when I'm
playing around.

-- Dave Kimmel
   crisco_kid at shaw.ca



More information about the geeks mailing list