[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: class memebers

Gabriel Genellina

12/19/2007 11:28:00 PM

En Wed, 19 Dec 2007 17:17:43 -0300, N L <nl_uc@yahoo.com> escribió:

> How do I list the members of a class? Meaning, how do I know what are
> the functions a particular class has, if i do not want to manually
> browse through the class?

From the interpreter, just print dir(class) or dir(instance); that
includes both attributes and methods. Or use the interactive help:
help(class), help(class.method)

Inside a program, use the inspect module: getmembers() retrieves all
members (both attributes and methods), you can filter that using the
various isXXX() functions.

--
Gabriel Genellina