[Python-Dev] PEP 395: Module Aliasing
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Fri Mar 4 16:59:59 CET 2011
More information about the Python-Dev mailing list
Fri Mar 4 16:59:59 CET 2011
- Previous message: [Python-Dev] PEP 395: Module Aliasing
- Next message: [Python-Dev] PEP 395: Module Aliasing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 03:30 pm, ncoghlan at gmail.com wrote: > > >Fixing dual imports of the main module >-------------------------------------- > >Two simple changes are proposed to fix this problem: > >1. In ``runpy``, modify the implementation of the ``-m`` switch >handling to > install the specified module in ``sys.modules`` under both its real >name > and the name ``__main__``. (Currently it is only installed as the >latter) >2. When directly executing a module, install it in ``sys.modules`` >under > ``os.path.splitext(os.path.basename(__file__))[0]`` as well as under > ``__main__``. > >With the main module also stored under its "real" name, imports will >pick it >up from the ``sys.modules`` cache rather than reimporting it under a >new name. Something to consider here is how this will interact with Python files which are _not_ modules. I'm a little uneasy about having sys.modules["trial"] refer to the module defined by /usr/bin/trial. Jean-Paul
- Previous message: [Python-Dev] PEP 395: Module Aliasing
- Next message: [Python-Dev] PEP 395: Module Aliasing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list