OK, I can't reproduce it either, neither in python3 nor python2. Brett, is this left over from a long time ago?
Heh. I just tried another experiment and got an interesting result:
rdmurray@pydev:~/python/p34>cat temp1.py
import temp2
foo = 1
rdmurray@pydev:~/python/p34>cat temp2.py
import temp1
badval
rdmurray@pydev:~/python/p34>./python
Python 3.4.3+ (3.4:b53cfcfdfe47, May 2 2015, 12:51:46)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import temp2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rdmurray/python/p34/temp2.py", line 3, in <module>
badval
NameError: name 'badval' is not defined
>>> import sys
>>> sorted(sys.modules.keys())
['__main__', '_codecs', '_collections_abc', '_frozen_importlib', '_imp', '_io', '_sitebuiltins', '_stat', '_sysconfigdata', '_thread', '_warnings', '_weakref', '_weakrefset', 'abc', 'atexit', 'builtins', 'codecs', 'encodings', 'encodings.aliases', 'encodings.latin_1', 'encodings.utf_8', 'errno', 'genericpath', 'io', 'marshal', 'os', 'os.path', 'posix', 'posixpath', 'readline', 'rlcompleter', 'signal', 'site', 'stat', 'sys', 'sysconfig', 'temp1', 'zipimport']
>>> import temp1
>>> temp1.temp2
<module 'temp2' from '/home/rdmurray/python/p34/temp2.py'>
>>> sorted(sys.modules.keys())
['__main__', '_codecs', '_collections_abc', '_frozen_importlib', '_imp', '_io', '_sitebuiltins', '_stat', '_sysconfigdata', '_thread', '_warnings', '_weakref', '_weakrefset', 'abc', 'atexit', 'builtins', 'codecs', 'encodings', 'encodings.aliases', 'encodings.latin_1', 'encodings.utf_8', 'errno', 'genericpath', 'io', 'marshal', 'os', 'os.path', 'posix', 'posixpath', 'readline', 'rlcompleter', 'signal', 'site', 'stat', 'sys', 'sysconfig', 'temp1', 'zipimport']
More or less the reverse of the passage in question. |