m...@distorted.org.uk (Mark Wooding) writes:

>> So even if the globals() dictionary is custom, its __setitem__ method is
>> *not* called.
>
> Fascinating.  Thank you.

In case it's not obvious, that is because CPython assumes the type for
many of its internal or semi-internal structures, and calls the
appropriate functions, such as dict.__setitem__ (PyDict_SetItem in C)
directly.  So python doesn't break the encapsulation of dict itself, it
just takes the liberty to assume that globals() is a non-subclassed
dict, at least as far as __setitem__ is concerned.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to