How Do I get Know What Attributes/Functions In A Class?
Hans Nowak
hans at zephyrfalcon.org
Sun Feb 20 01:03:44 EST 2005
steven at lczmsoft.com wrote:
> Hi,
>
> I'm new to python. Given a class, how can I get know what
> attributes/functins in it without dig into the source?
Use the dir function:
>>> from smtplib import SMTP
>>> dir(SMTP)
['__doc__', '__init__', '__module__', 'close', 'connect', 'data',
'debuglevel', 'docmd', 'does_esmtp', 'ehlo', 'ehlo_resp', 'expn',
'file', 'getreply', 'has_extn', 'helo', 'helo_resp', 'help', 'login',
'mail', 'noop', 'putcmd', 'quit', 'rcpt', 'rset', 'send', 'sendmail',
'set_debuglevel', 'starttls', 'verify', 'vrfy']
To get more detailed information than just a list of names, see the
inspect module.
--
Hans Nowak
http://zephyrfalcon.org/
More information about the Python-list
mailing list