> On Wednesday, April 16, 2014 2:57:35 PM, Terry Reedy <tjre...@udel.edu
> <mailto:tjre...@udel.edu>> wrote:

>     PS. In the user process sys.modules, there are numerous null
>     entries like these:
>       >>> sys.modules['idlelib.os']
>       >>> sys.modules['idlelib.tokenize'__]
>       >>> sys.modules['idlelib.io <http://idlelib.io>']
>       >>> <etcetera>

On 4/16/2014 3:10 PM, Dr. Brett Cannon wrote:
Is this Python 2 or 3?

Py 2. I should have said so. The entries do not appear in py3.

In Python 2 it means an attempt to perform a relative import failed but
an absolute in succeeded, e.g. from idlelib you imported os, so import
> tried idlelib.is <http://idlelib.is> and then  os.

*I* have not done anything. For tokenize, for instance, the existing code just does what I though were absolute imports, in 2 files.
  import tokenize

Perhaps the extra entries have something to do with the fact that these startup imports are invisible to user code, just like those done by the interpreter itself on startup. 2.7 uses spawnv (and 3.4 uses subprocces) to run something like one of the following.
  python -c "__import__('idlelib.run').run.main(False)"
  python -c "__import__('run').main(False)"

run.py has several normal lines with
  import <stdlib module>
  from idlelib import <idlelib module>
and ditto for some of the imported idlelib modules.

> You should definitely consider using a future import to guarantee
absolute imports.

--
Terry Jan Reedy

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to