[issue16737] Different behaviours in script run directly and via runpy.run_module

Nick Coghlan report at bugs.python.org
Sun Dec 11 20:42:04 EST 2016


Nick Coghlan added the comment:

Something we don't really have anywhere is a short summary of how sys.path[0] gets initialised - it's scattered through the descriptions of the various invocation options in https://docs.python.org/3/using/cmdline.html#interface-options

I figure it's also worth mentioning https://bugs.python.org/issue13475 where we discussed the idea of a "--nopath0" option so folks could easily disable imports from the current directory (-c, -m) or from the script directory (direct execution) without otherwise impacting startup behaviour. (Specifying --nopath0, and then requesting execution of a directory or zipfile would necessarily be an error, since modifying sys.path[0] is an essential part of making those work)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16737>
_______________________________________


More information about the Python-bugs-list mailing list