Retrieving the full command line
mail at timgolden.me.uk
Tue Jan 22 10:24:23 CET 2013
[Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific,
I use the python -mpackage incantation to run a package which has a
__main__.py module and which uses relative imports internally.
I'm developing under cherrypy which includes a reloader for development.
The reloader attempts to rebuild the original
command line by combining sys.executable and sys.argv and then does an
There does not appear to be any way within Python of determining the
command line I used. The combination of sys.executable and sys.argv in
this case will look like: "c:\python33\python.exe app/__main__.py". But
running this precludes the use of package-relative imports.
I can pull the command line out of the Windows API to solve this
specific problem, but is there not a gap here? Even if sys.flags somehow
indicated the -m (it doesn't) that wouldn't give me the filepath which
Have I missed something?
More information about the Python-list