Howto: creating empty modules?

Alex Martelli aleax at aleax.it
Wed Jan 9 12:00:29 EST 2002


"Janko Hauser" <jhauser at ifm.uni-kiel.de> wrote in message
news:87n0znjyql.fsf at ifm.uni-kiel.de...
    ...
> > using a Python release older than 2.1, a class or an instance
> > cannot be registered in sys.modules (it's OK from 2.1 onwards).
> >
> Had not thought about functions. Basically this amounts to a a global
> namespace (sys.modules) from which one explicitly imports new
> namespaces, modules or classes. Are there many common uses of this
> namespace handling/changing?

Not really -- almost always, the automatic addition of modules
into sys.modules as they are first loaded does what one wants.

One can play several neat-o tricks with imports, sys.modules,
importing non-modules, importing modules without involving sys.modules,
building modules on the fly without importing, etc, etc, but I
don't think any of these neat tricks are *commonly* needed.


Alex






More information about the Python-list mailing list