[Python-3000] Confused about getattr() and special methods (original) (raw)

Thomas Wouters thomas at python.org
Tue Sep 4 12:00:16 CEST 2007


On 9/4/07, Thomas Heller <theller at ctypes.org> wrote:

Shouldn't the getattr implementation find the iter method of the stream instance variable?

No. For new-style classes, the special methods (that are part of the PyType C struct) are always looked up on the class, never the instance. The class's getattr is never called. It's the class that defines behaviour, and getattr and getattribute just define how to handle instance attribute access.

This change is really the biggest difference between classic classes and new-style classes, much bigger than the MRO change ;-)

-- Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-3000/attachments/20070904/df911e34/attachment.htm



More information about the Python-3000 mailing list