deleting global namespaces

Thomas Wouters thomas at xs4all.net
Sat Feb 5 12:01:09 EST 2000


On Sat, Feb 05, 2000 at 04:15:21PM +0000, martindvorak at my-deja.com wrote:

> > If you then wish to reset to the initial state, just create a new
> > module.Module object.

> That's clear but it does not solve my problem. I know
> objects and use them extensively, but I need to divide
> the whole application (which consists of hundrends
> of objects) into independent components each with its own
> global namespace so that component's objects can
> use this global namespace independently on other
> objects in other components.

I guess I still dont understand the problem. You can place these objects
each in its own module, giving each a seperate global namespace. IMHO, if
you are relying on a module-level attribute to be in a specific state, as
set by module initialization, you either have to create a function to reset
them to that state (which seems simple, to me, but see the first line of
this paragraph) or your attributes are in the wrong place.

Also, dont forget that you can set module-level attributes from class
__init__ methods (and, of course, other class methods as well.) You just
have to be very careful that you only have one object instantiated, if you
rely on module-level attributes. Are you sure you can't do what you want
by replacing the references to 'attribute' by 'self.attribute' ?

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list