FEEDBACK WANTED: Type/class unification
robin at jessikat.fsnet.co.uk
Tue Aug 14 18:54:08 CEST 2001
In article <cp7kw6em6n.fsf at cj20424-a.reston1.va.home.com>, Guido van
Rossum <guido at python.org> writes
>> I guess what I'm trying to get at is can getset be used to create a
>> readonly module level global or can it only be used for attributes.
>The getset descriptor works in cooperation with the default
>__getattr__ implementation. When a.foo is requested, __getattr__
>looks up a.__class__.foo first; if this is found and it is a
>descriptor, the descriptor's __get__ is called to finish the
>__getattr__ request. Ditto for __setattr__.
>If you could subclass modules (you can't yet in 2.2a1, but you will in
>2.2), you could do this for module attribute references, but global
>variable references don't go through __getattr__ and __setattr__ on
>the module -- they use the C APIs PyDict_GetItem and PyDict_SetItem
>and you can't override those.
>--Guido van Rossum (home page: http://www.python.org/~guido/)
OK I'll bite. What's a module attribute? I naively thought that
makes X a global in M and also an attribute of module M? Obviously I'm
wrong. Are there things (apart from builtins etc) which are more global
than X in M's scope?
More information about the Python-list