e4m...@gmail.com wrote:
> 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.
> 
It isn't.

> 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
> modules.
> 
Think of the import statement as giving access to a particular
namespace, with the side-effect of loading the code if it's the first
import.

> 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?
> 
Import each module into every other module that requires its functionality.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/

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

Reply via email to