On Wed Apr 16 2014 at 4:53:25 PM, Terry Reedy <tjreedy at udel.edu> wrote: > > On Wednesday, April 16, 2014 2:57:35 PM, Terry Reedy <tjreedy at udel.edu > > <mailto:tjreedy at 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.os 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 > That's not an absolute import if it's within a package and you didn't declare `from __future__ import absolute_import`. > > 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)" > Nope, it has to simply do with how Python 2 does implicit relative imports. Add the __future__ statement and they will go away. -Brett > > 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 at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ > brett%40python.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140417/9bb4ce2a/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4