[Tutor] atr in dir Vs. hasattr
Tom Zych
freethinker at pobox.com
Wed Mar 16 14:30:59 CET 2011
On Thu, 17 Mar 2011 00:12 +1100, "Steven D'Aprano" <steve at pearwood.info>
wrote:
> And here's an example:
>
> >>> class C(object):
> ... pass
> ...
> >>> hasattr(C, '__eq__')
> True
> >>> '__eq__' in dir(C)
> False
OTOH, I got True in 3.1.1. As the docs say, detailed behavior may change
across releases.
I suppose there must be some reliable way to get a list of *all* an
object's attributes,
but I don't see it.
--
Tom Zych / freethinker at pobox.com
More information about the Tutor
mailing list