On Thu, Apr 7, 2011 at 3:31 PM, andrew cooke <and...@acooke.org> wrote:
>
> In the code below I use __prepare__ to change the class dictionary so that a 
> tuple is stored in __setitem__().  Since __getitem__() removes the tuple I 
> wasn't expecting any problems, but it seems that __init__ is being retrieved 
> via some other mechanism.  Why?

I suspect you're being bitten by
http://docs.python.org/dev/reference/datamodel.html#special-method-lookup

In particular: "implicit special method lookup generally also bypasses
the __getattribute__() method".

__init__() is a special method.
The default __getattribute__() implementation consults an object's __dict__.
type.__new__() presumably does an implicit special method lookup for
__init__() behind the scenes.

Hence, your custom __dict__ is bypassed.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to