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

I would have expected that the object returned by getattr would be the
same object as the object returned by standard attribute access. This is
true for some attributes, but not for __dict__. I don't know if there are
other examples.

Why is this? Is there some documentation I can read up about this? I've
tried searching, but can't find anything useful.



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to