[Python-3000] [stdlib-sig] PEP 3108 - stdlib reorg/cleanup

Brett Cannon brett at python.org
Tue Apr 29 23:18:47 CEST 2008


On Tue, Apr 29, 2008 at 1:57 PM, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 4/29/08, Brett Cannon <brett at python.org> wrote:
[SNIP]
>
>  >  >  I'd like to see the PEP address the question of how it is going to deal
>  >  > with getting duplicate copies of modules in sys.modules when some code in an
>  >  > application uses the old name and some code uses the new name.
>
>  > There is not much that can be done without introducing a custom
>  >  importer to handle the mapping of names in sys.modules to the same
>  >  module object. Otherwise it's going to be done using ``from _ import
>  >  *``.
>
>  The following worked on python 2.5
>
>  zort.py
>  ---------
>
>  import sys
>  import collections
>  sys.modules[__name__]=collections
>
>  >>> import zort
>  >>> zort is collections
>  True
>

Huh. That is a much better solution. I just didn't think that was
going to work. But both import.c and importlib return the module found
in sys.modules in the end, so the trick works. I will update the PEP!

-Brett


More information about the Python-3000 mailing list