Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82172

Re: module import questions and question about pytest and module imports

References <CAPti5iMacuhtNhGg_YkqdkW+X36R6bzRTo_RWn-KMq0CwczAOQ@mail.gmail.com> <54847FAF.8040006@davea.name> <CAPti5iPBG_YiG-ZUu_ZQD8qdg91Oq_6CXoJ-9t9vRFwtNYL4rA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-12-08 19:22 -0700
Subject Re: module import questions and question about pytest and module imports
Newsgroups comp.lang.python
Message-ID <mailman.16756.1418091788.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton <samp4040@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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: module import questions and question about pytest and module imports Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-08 19:22 -0700

csiph-web