Philippe C. Martin wrote:
Thank you all for your answers, I guess I would not have made Python 101:-)

As far as I was concerned, importing a module twice would have resulted in loading the file twice.

Background on that: importing the module the first time causes the code in it to be executed (i.e. all those def statements and such) and the resulting module gets a reference stored in sys.modules (which is a dictionary you might want to examine at the prompt to see how it looks). Any subsequent "import" of the same module will just retrieve a reference to it from sys.modules, so the second and later imports are effectively instantaneous...

-Peter
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to