New submission from Nick Coghlan <ncogh...@gmail.com>:

PEP 395 spends a lot of time discussing ways that the current automatic 
initialisation of sys.path[0] can go wrong, and even the proposed improvements 
in that PEP don't claim to fix the default behaviour for every possible 
scenario (just many of the most common ones).

The unittest module gets around similar problems with test autodiscovery by 
providing an explicit "-t" (for 'toplevel') command line option.

While '-t' is not available for the main interpreter executable (and nor is 
'-d' for directory), '-p' for "path0" is a possibility.

Directory execution (for example) would then be equivalent to:

  python -p dirname dirname/__main__.py

A separate '--nopath0' option could also be provided to explicitly disable path 
initialisation based on the script being executed (see 
http://lists.debian.org/debian-python/2011/11/msg00058.html)

----------
messages: 148295
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Add '-p'/'--path0' command line option to override sys.path[0] 
initialisation

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13475>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to