Re: Getting a list of an object's methods?
Gerrit Holl wrote:
> Jeremy Yallop wrote:
>> Unfortunately, this isn't any better than the original idea of using
>> dir(), since inspect.getmembers is implemented using dir(). As the OP
>> noted, dir() isn't reliable. For example, 'mro' isn't in int's dir(),
>> although it is (the name of) a method of type and in type's __dict__.
> Hm, how does readline does this? I use readline and I do get 'mro'
> for an int when pressing tab:
> Readline appears to be implemented in C. Hmm...
Readline is indeed implemented in C, but the function which completes
the partial member names is written in Python: see the Completer class
in the rlcompleter module. The actual implementation is rather
simple: it calls dir on the instance, its class and (recursively) its
The code is fairly straightforward and might at least give the OP some
|All times are GMT. The time now is 01:51 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.