FEEDBACK WANTED: Type/class unification
Guido van Rossum
guido at python.org
Fri Aug 17 21:37:10 EDT 2001
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/)
More information about the Python-list
mailing list