strange import phenomenon
Christoph Zwerschke
cito at online.de
Thu Sep 22 19:02:15 EDT 2005
Thank you, Dieter! Bingo.
When I think about it now, it is very logical: There must be another
mechanism besides sys.path, otherwise modules inside packages would not
find their siblings or subpackages.
But whereever the search path is explained, only sys.path was mentioned,
so I took that at face value. There is a small note in the tutorial, but
it is not very clear and in section 6.4.3 where you don't expect it. The
section 6.1.1 about the module search path does not mention it.
If I want test2.py to find only the modules in the search path, how
should I proceed? One idea that seems to work is setting
__name__ = '__main__'
in test2.py, but I don't know whether that is proper. Any idea?
Thanks again,
Christoph
More information about the Python-list
mailing list