faqts : Computers : Programming : Languages : Python : Snippets

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 0 of 1 people (0%) answered Yes

Entry

Getting all methods of a class (was: dir() and property list)

Jul 5th, 2000 10:03
Nathan Wallace, Hans Nowak, Snippet 325, Donn Cave


"""
Packages: oop
"""
"""
| Is it possible to get the functions of an object using dir()? Rather
| that looking them up in a book/API.
Yes, though not directly through the object and it's not real simple.
"""
def printcdir(c):
   print dir(c)
   for b in c.__bases__:
       printcdir(b)
def printxdir(instance):
   print dir(instance)
   printcdir(instance.__class__)