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


Groups > comp.lang.python > #102757

Re: Importing two modules of same name

From dieter <dieter@handshake.de>
Newsgroups comp.lang.python
Subject Re: Importing two modules of same name
Date 2016-02-10 08:54 +0100
Message-ID <mailman.1.1455090890.22075.python-list@python.org> (permalink)
References <20160209232303.GC2583@mail.akwebsoft.com> <56BA7809.1000206@oddbird.net>

Show all headers | View raw


Carl Meyer <carl@oddbird.net> writes:
> ...
> If you omit the future-import in Python 2.7, `import config` will import
> the neighboring app/config.py by default, and there is no way to import
> the top-level config.py.

There is the "__import__" builtin function which allows to specify
the "parent package" indirectly via its "globals" parameter. This
way, you can import the "top-level" config (passing an empty "globals").

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


Thread

Re: Importing two modules of same name dieter <dieter@handshake.de> - 2016-02-10 08:54 +0100

csiph-web