John Machin
2008-12-09 04:44:53 UTC
? ?_map = {}
How do I make sure this only gets initialized the *first* time the
module containing the class is imported? ?What appears to be happening
as it stands is each time the module gets imported, Foo._map get re-
initialized.
Unless you are calling reload() on the module, it will only ever getHow do I make sure this only gets initialized the *first* time the
module containing the class is imported? ?What appears to be happening
as it stands is each time the module gets imported, Foo._map get re-
initialized.
_loaded_ once. Each additional import will just yield the existing
module. Perhaps if you post an example of the behavior that leads you
to believe that the class variables are getting reinitialized
class Foo(object):
because we care little about old-style classes these days
and put a print statement in the module just before the class
statement and print statements before and after each import statement
so that we can see what is happening.