On Sun, Aug 24, 2008 at 9:59 AM, Fredrik Lundh <fredrik@python ware.comwrote:
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 ?
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
Regards,
Mohamed Yousef
Mohamed Yousef wrote:
>
>
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 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
>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).
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)
>
>
to do that, add "import re" to the top of the C module.
actually loads the module)
>
>my goal is basically making W() aware of the re module when called
>from A
>from A
to do that, add "import re" to the top of the C module.
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
Comment