strange import phenomenon

Christoph Zwerschke cito at
Fri Sep 23 01:02:15 CEST 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 to find only the modules in the search path, how 
should I proceed? One idea that seems to work is setting

    __name__ = '__main__'

in, but I don't know whether that is proper. Any idea?

Thanks again,

More information about the Python-list mailing list