Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: dieter Newsgroups: comp.lang.python Subject: Re: Importing two modules of same name Date: Wed, 10 Feb 2016 08:54:42 +0100 Lines: 10 Message-ID: References: <20160209232303.GC2583@mail.akwebsoft.com> <56BA7809.1000206@oddbird.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.uni-berlin.de 8jDieuzTX79sCcWs2fI6zAtN/MJakYqCGMIENk00KI7g== Cancel-Lock: sha1:0QpREuDAyOzkLWfPAlLXEKlj83Q= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'builtin': 0.07; 'omit': 0.07; 'subject:two': 0.07; 'parameter.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:modules': 0.09; 'subject:same': 0.09; 'python': 0.10; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'config': 0.18; 'default,': 0.22; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'specify': 0.27; 'function': 0.28; 'indirectly': 0.29; 'allows': 0.30; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'received:217': 0.66; 'meyer': 0.84; 'package"': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pd9e09e05.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102757 Carl Meyer 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").