python - IPython import local file -
i've come across weird disparity between ipython , default python interpreter. have python file shadows built-in module's name: logging.py. has simple method foo().
if start default python interpreter , call import logging
imports local file , can access logging.foo()
.
if start ipython , call import logging
imports python built-in module. if change name non-shadow (e.g. import my_logging
) import work expected.
which expected behaviour? current directory @ start of sys.path
both interpreters differ in imports have priority.
import sys print(sys.modules)
ipython starts of standard library imported, including logging. modules seem imported full path.
speculation: ipython imported libraries full path internal use, when import logging
again checks module imported, regardless of path, , nothing.
Comments
Post a Comment