Imports awareness in Imported modules problem

Mohamed Yousef harrrrpo at
Sun Aug 24 12:34:41 CEST 2008

On Sun, Aug 24, 2008 at 9:59 AM, Fredrik Lundh <fredrik at> wrote:
> Mohamed Yousef wrote:
>> why am i doing this in the first place
>> I'm in the process of a medium project where imports of modules start
>> to make a jungle and i wanted all needed imports to be in a single
>> file (namely
>> and then all imports are made once and other modules feel it
> Python doesn't use a global namespace -- importing a given module into one
> module doesn't make it visible everywhere else (and trust me, this is a very
> good thing).
why isn't it a good thing (even if optional)
consider the sitution in which a utility module is used every where
else - other modules -
you may say import it in them all , what i changed it's name ? go back
change all imports... this doesn't seem good
and what about package wide varailbles ?
> (it uses a global module cache, though, so it's only the first import that
> actually loads the module)
>> my goal is basically making W() aware of the re module when called
>> from A
> to do that, add "import re" to the top of the C module.
and sys  ,string.. etc add them all twice or four / n times ?
remove one and then forget to remove one of them in a file and start
debugging ... this really doesn't look to be a good practice
> see this page for a little more on Python's import mechanism:

Mohamed Yousef

More information about the Python-list mailing list