Unexpected behaviour of getattr(obj, __dict__)
bruno at modulix
onurb at xiludom.gro
Tue Feb 14 07:03:17 EST 2006
Steven D'Aprano wrote:
> I came across this unexpected behaviour of getattr for new style classes.
> Example:
>
>
>>>>class Parrot(object):
>
> ... thing = [1,2,3]
> ...
>
>>>>getattr(Parrot, "thing") is Parrot.thing
>
> True
>
>>>>getattr(Parrot, "__dict__") is Parrot.__dict__
>
> False
hint:
>>> getattr(object, '__dict__')
<dictproxy object at 0x2aaaaab2ff30>
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list