Importing modules

e4me4m at e4me4m at
Wed Jan 7 18:29:06 CET 2009

Coming from a scripting background where we used to write everything
into one script, I'm now going modular with Python. I place related
functions in one module, and other functions in other modules.

This all works OK, but I'm a bit confused about importing modules from
the standard library. For example, say 3 of my 12 modules use os and
os.path. Right now, I have import statements in all 3 modules that
import both os and os.path. This seems wrong to me.

I read the docs and understand that before loading a module that
Python is smart enough to look and see if it's already loaded, so
there is no performance issue (it would seem), but I was thinking
there is probably a way to load all the modules I need in some orderly
fashion without having these multiple import statements in my separate

Could someone point me to some docs that explain the Python way of
loading modules when breaking old, big (everything in one script) into
more manageable modular scripts?



More information about the Python-list mailing list