Multiple instances of modules
posman at eval.ca
Mon Sep 15 17:46:46 CEST 2003
On Mon, 15 Sep 2003, Daniel Pryde wrote:
> For example, say I made a CD.py module which held details of an audio
> compact dic (album name, track names, etc..), and wanted my Python
> script to make a record collection using multiple CD's, I can't make
> them seperately. I tried using the 'import module as name' format, but
> any changes made to one instance affects the other. I assume this is
> because Python is simply referencing the one instance of CD.py rather
> than seperate ones. Is there a solution to this that doesn't involve
> using cPython or Jython? Any help would be greatly appreciated.
Why not just use a class within the CD module? Then you could create as many
instances of that class as you'd like.
paul at eval.ca
"Idealists...foolish enough to throw caution
to the winds...have advanced mankind and have
enriched the world."
- Emma Goldman
More information about the Python-list