Importing modules

Paul McGuire ptmcg at austin.rr.com
Wed Jan 7 12:53:17 EST 2009


...and don't worry about a possible performance issue of importing os
(or any other module) multiple times - the Python import manager is
smart enough to recognize previously imported modules, and wont import
them again.

If a module uses the os module, then it should import it - that's just
it.

Another consideration might be that you are breaking up your own
program modules too much.  For instance, if I had a program in which I
were importing urllib in lots of modules, it might indicate that I
still have some regrouping to do, and that I could probably gather all
of my urllib dependent code into a single place.

-- Paul



More information about the Python-list mailing list