On Tue, Apr 29, 2008 at 1:57 PM, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 4/29/08, Brett Cannon <[EMAIL PROTECTED]> 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 _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com