object aware of others
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Jan 28 23:13:21 EST 2012
On Sun, 29 Jan 2012 16:48:34 +1300, Lee Chaplin wrote:
[...]
> The last four lines work if they are in the same module as the class
> definitions (a000), but it doesn't work if they are called from a
> different module, say:
globals() is not actually global to the entire Python session. It
actually means global to a module. Every module has its own globals().
Python doesn't really have a concept of "global to the entire session" as
such, although the built-ins comes close. But if you mess with built-ins,
people will be sarcastic at you. They may even use irony.
However, you can fetch another module's globals by using:
vars(module)
--
Steven
More information about the Python-list
mailing list