module import questions and question about pytest and module imports

Ian Kelly ian.g.kelly at gmail.com
Mon Dec 8 21:22:18 EST 2014


On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton <samp4040 at gmail.com> wrote:
> Having to put the garage package on the sys.path seems a little off,
> why wouldn't relative imports work?

Relative imports are relative to a package's hierarchy of namespaces, not
relative to the file system. As such, you can't perform a relative import
of a module that isn't in the same top-level package (and besides this, the
import statement that you posted was an absolute import anyway).

All top-level packages have to be on sys.path, or the import system won't
be able to find them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141208/6f7d4042/attachment.html>


More information about the Python-list mailing list