Importing two modules of same name

Tim Johnson tim at akwebsoft.com
Wed Feb 10 14:26:48 EST 2016


* dieter <dieter at handshake.de> [160209 23:03]:
> Carl Meyer <carl at 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").
  Thanks.
  I used __import__ as part of a custom load() function that I used
  in my own framework when I was developing CGI sites. I never used
  the globals parameter tho'.
  If I start

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



More information about the Python-list mailing list