![]() |
Re: Getting a list of an object's methods?
Alexander Schmolck wrote:
> The premises are right, but they don't entail the conclusion. `dir`s behavior > is not guaranteed to be stable, but `inspect.getmembers`'s obviously is [1]. [further logic and "obvious" things snuipped] All very well, but inspect.getmembers is implemented using dir() /now/, and doesn't return all of the methods in the /currently-existing/ versions of Python that the OP wants to use. It isn't an appropriate solution, unfortunately. > I don't think "What methods does this object have?" is a question > that only a python wizard should be able to ask and receive a > well-defined answer. Well, that's certainly true. Jeremy. |
Re: Getting a list of an object's methods?
Jeremy Yallop <jeremy@jdyallop.freeserve.co.uk> wrote in
news:bd7qdu$pkgc5$2@ID-114079.news.dfncis.de: > Alexander Schmolck wrote: >> The premises are right, but they don't entail the conclusion. `dir`s >> behavior is not guaranteed to be stable, but `inspect.getmembers`'s >> obviously is [1]. > > [further logic and "obvious" things snuipped] > > All very well, but inspect.getmembers is implemented using dir() /now/, > and doesn't return all of the methods in the /currently-existing/ > versions of Python that the OP wants to use. It isn't an appropriate > solution, unfortunately. > >> I don't think "What methods does this object have?" is a question >> that only a python wizard should be able to ask and receive a >> well-defined answer. > > Well, that's certainly true. > > Jeremy. > The dir(self.__class__) works OK for me, since they're all wacky custom classes. I would still like to know why, in Python 2.1, none of the methods show up for when using dir() (or __dict__) on an instance of the class. It's really quite odd :) >>> len(dir(blah)), len(dir(blah.__dict__)) (24, 24) >>> len(dir(blah.__class__)), len(dir(blah.__class__.__dict__)) (49, 49) Thanks to the various people who helped me out again :) Freddie -------------------------------------------------------------- Remove the z's from my e-mail address if you really want to |
| All times are GMT. The time now is 06:33 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.