Python interactive shell running copy.py on current directory? -
i have script named copy.py
on current directory following content:
#!/usr/bin/env python3 print("ahoy, matey!")
if run python interactive shell , action raise exception (e.g. referring non-existent variable), surprise, sentence "ahoy, matey!" got printed.
when rename copy.py
script else, e.g. script.py
, no longer behaves that. question is, why interactive shell have call copy.py
on error? behavior expected and/or documented somewhere?
thanks!
when python imports module, module search path order is:
- the directory containing input script (or current directory).
- pythonpath (a list of directory names, same syntax shell variable path).
- the installation-dependent default.
now, when raising exception, python runs specific code. code tries import copy
python module instead import module , print string in it. why shouldn't use names names of standard python modules.
Comments
Post a Comment