Importing modules

Mel mwilson at the-wire.com
Wed Jan 7 13:06:53 EST 2009


Steve Holden wrote:

> e4me4m at gmail.com wrote:
[ ... ]
>> 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.

True.  The O.P. can note one of the miracles of Python: (for an example,
I'll pick a library module at random .. image)  One can write a module  --
myimage.py, say, that imports image, and has some functions that return
objects based on calls to image functions.

A program that imports myimage can use these objects in all possible ways
and not have to import image.  It doesn't need to know anything about just
where myimage gets its stuff.  Importing only strictly needs to be one
level deep.  (Of course, the programmer needs to know what all those
possible ways are.  The programmer may have to have read the docs for the
image module ... )

        Mel.




More information about the Python-list mailing list