All functions from self and inherited classes
Skip Montanaro
skip at pobox.com
Tue Jun 12 17:01:53 EDT 2001
>> And a dir(self.__class__) returns methods, but only methods defined
>> in B.
Alex> Someone posted this code here ages ago.... [snipped]
The (new) standard module inspect has a getmembers function (output wrapped
for readability):
>>> httplib.HTTP
<class httplib.HTTP at 0x823a64c>
>>> inspect.getmembers(httplib.HTTP)
[('__doc__', 'Compatibility class with httplib.py from 1.5.'),
('__init__', <unbound method HTTP.__init__>), ('__module__', 'httplib'),
('_connection_class', <class httplib.HTTPConnection at 0x8239dec>),
('_http_vsn', 10), ('_http_vsn_str', 'HTTP/1.0'),
('close', <unbound method HTTP.close>),
('connect', <unbound method HTTP.connect>), ('debuglevel', 0),
('getfile', <unbound method HTTP.getfile>),
('getreply', <unbound method HTTP.getreply>),
('putheader', <unbound method HTTP.putheader>),
('set_debuglevel', <unbound method HTTP.set_debuglevel>)]
>>> h = httplib.HTTP()
>>> inspect.getmembers(h)
[('_conn', <httplib.HTTPConnection instance at 0x82388d4>),
('cert_file', None),
('endheaders', <method HTTPConnection.endheaders of HTTPConnection instance at 0x82388d4>), ('file', None), ('key_file', None), ('putrequest', <method HTTPConnection.putrequest of HTTPConnection instance at 0x82388d4>), ('send', <method HTTPConnection.send of HTTPConnection instance at 0x82388d4>)]
--
Skip Montanaro (skip at pobox.com)
(847)971-7098
More information about the Python-list
mailing list