FEEDBACK WANTED: Type/class unification

Robin Becker robin at jessikat.fsnet.co.uk
Sat Aug 18 04:00:15 EDT 2001


In article <cp1ymadub3.fsf at cj20424-a.reston1.va.home.com>, Guido van
Rossum <guido at python.org> writes
>Robin Becker <robin at jessikat.fsnet.co.uk> writes:
>
>> >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
>> 
>> #M.py
>> X=3
>> ....
>> 
>> 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?
>
>It's purely a syntactical question.  When used from inside the module,
>it's a global.  When used from the outside as M.X, it's a module
>attribute.
>
>--Guido van Rossum (home page: http://www.python.org/~guido/)
Ok so is the implication that external references to M.X could possibly
be controllable by get/set mechanisms, but inside M such controls
wouldn't work? Inside M you could presumably import M and work with M.X.
-- 
Robin Becker



More information about the Python-list mailing list