Retrieving the full command line

T

Tim Golden

[Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific,
though].

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
execv.

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
it used.

Have I missed something?

TJG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top