On Sun, Aug 24, 2008 at 9:59 AM, Fredrik Lundh <[EMAIL PROTECTED]> 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 __init__.py) >> 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: > > http://effbot.org/zone/import-confusion.htm >
Regards, Mohamed Yousef -- http://mail.python.org/mailman/listinfo/python-list