[Python-Dev] Python program name

Antoine Pitrou solipsis at pitrou.net
Fri May 4 14:33:47 CEST 2012


On Fri, 4 May 2012 13:29:14 +0100
Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> 
> On 4 May 2012, at 09:44, Vinay Sajip wrote:
> 
> > IIUC, the program name of the Python executable is set to whatever argv[0] is.
> > Is there a reason for this, rather than using one of the various OS-specific
> > APIs [1] for getting the name of the running executable? The reason I ask is
> > that in a virtual environment (venv), the exe's path is the only thing you have
> > to go on, and if you don't have that, you can't find the pyvenv.cfg file and
> > hence the base Python from which the venv was created.
> 
> 
> argv[0] is the *script* name, not the executable name - surely?
> 
> The executable path is normally available in sys.executable.

I think Vinay is talking about C argv, not sys.argv.

Regards

Antoine.




More information about the Python-Dev mailing list