[Python-Dev] unexpected import behaviour

Oleg Broytman phd at phd.pp.ru
Fri Jul 30 18:59:45 CEST 2010


On Fri, Jul 30, 2010 at 07:26:26AM +0100, Daniel Waterworth wrote:
> @Oleg: ...
> This is purely CPython bug-fixing/the discussion of
> implementation choices.

   I am not sure it's a bug. By manipulating sys.path (or symlinks in the
FS) one can import the same file as different modules as many times as
[s]he wants. Should this be fixed for __main__? I doubt it. Instead of
making __main__ a special case follow the rule: don't import the same
module under different paths/names.
   Make your script simply

from test import main
main()

Oleg.
-- 
     Oleg Broytman            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-Dev mailing list