[pygtk] dynamic namespace

John Ehresman jpe at wingware.com
Sat Jul 29 09:43:49 WST 2006


Johan Dahlin wrote:
>> The attached implementation of _lazyutils.py moves most of the logic
>> from __getattribute__ to __getitem__. This makes it possible to assume
>> that
>>
>> gtk.foo == gtk.__dict__['foo']
>>
> It won't work, because you cannot override __dict__ on a PyModule_Type.
> The generated code uses PyModule_GetDict on the gtk module, 
> __getattribute__ will not even be called for that attribute access.

Also, __getitem__ is not invoked by C calls to PyDict_GetItem() (even 
for subclasses of dict) so there's no way to get it to return a value 
unless it's already in the dictionary.

John


More information about the pygtk mailing list