On Sat, Mar 3, 2012 at 9:38 PM, Damjan Georgievski <gdam...@gmail.com> wrote: > How can I get the *really* original command line that started my python > interpreter? > > Werkzeug has a WSGI server which reloads itself when files are changed > on disk. It uses `args = [sys.executable] + sys.argv` to kind of > recreate the command line, and the uses subprocess.call to run that > command line. > > BUT that's problematic as, when you run:: > > python -m mypackage --config > > sys.argv printed in mypackage/__main__.py will be:: > > ['/full/path/to/mypackage/__main__.py', '--config'] > > so you get:: > > python /full/path/to/mypackage/__main__.py --config > > instead of:: > > python -m mypackage --config > > > the difference in the 2 cases is what the current package is, and > whether you can use relative imports.
On Linux, you can read from: /proc/<PID here>/cmdline to get the null-delimited "command line". Sidenote: Consensus generally seems to be that relative imports are a bad idea. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list