Load a module twice ... or not ???

Alex alex at somewhere.round.here
Tue Mar 21 20:13:29 CET 2000

> Now I have a reasonably complex Web application with just this
> structure, since I've modified PyApache to have a persistent
> interpreter to avoid the massive overhead of importing
> modules. Modules run as main programs and they also get imported by
> other modules running as main programs. All the modules have classes
> defined in them (I'm using more or less WvRA's cgiBase class
> structure). It works perfectly - never a problem.
> Since I don't, in practice, encounter any problems doing what WvRA say
> I shouldn't do, is this in fact an issue?

In your case, it's not an issue, because the main module isn't being
reloaded in the same program.  The problem you are asking about only
occurs when a python interpreter loads the same module twice.  It
doesn't have to be the main module, either.  Here is an example of the
sort of thing they were talking about:

class A:
    member = 'Original value'

>>> import A
>>> a1 = A.A ()
>>> reload (A)
<module 'A' from 'A.pyc'>
>>> a2 = A.A ()
>>> a2.member = 'New value'
>>> print a1.member
Original value
>>> print a2.member
New value


More information about the Python-list mailing list