Why the default sys.path[0] insertion? (It breaks my code.)

Martin v. Löwis martin at v.loewis.de
Fri Dec 20 18:15:10 EST 2002


Robb Shecter <rs at onsitetech.com> writes:

> No no no...  I do (for example) "import db"and expect it to be "db",
> but it ends up being "mpm.db".  

I see. This has nothing to do with sys.path modification - it is
normal package behaviour.

If you have a module mpm.mymod which is part of the mpm package, and
this module performs "import db", then the module being imported is
mpm.db. Relative imports are supported in Python.

> I'm trying to follow the rules, and not do relative imports, because
> as I understand it, you can't do them.

Your understanding is incorrect. You can do relative imports in
Python.

Regards,
Martin



More information about the Python-list mailing list