module data member?

Diez B. Roggisch deets at nospam.web.de
Tue Nov 13 12:53:11 EST 2007


Peter J. Bismuti schrieb:
> This did the trick for the most part, but it still leaves a copy of the 
> variable A in the "non-module" global namespace (see output below).  
> 
> I want A declared global to the module (so as not to be local within the 
> functions of the module) but not visible outside of the module namespace 
> (like B, see below). How can this be done?

It can't, unless you remove the A = 0 from the module and put it into 
some init function.

To quote myself:

"""
This of course won't prevent __main__ to be existant, nor running possible
initialization code twice. But if the module is supposed to do some work,
it will operate on the one data all the other importing modules see.
"""

You could of course delete everything in __main__ as well, but then...
why do you care about the __main__.A living?


Diez



More information about the Python-list mailing list