'-m' option (was RE: [Python-Dev] ConfigParser patches)
Guido van Rossum
gvanrossum at gmail.com
Sun Oct 3 06:33:09 CEST 2004
> Correct. Ilya's original example was wanting to invoke pdb's script behaviour in
> order to debug another script. At the moment, you have to run:
> python -c "from inspect import getsourcefile; import pdb; print getsourcefile(pdb)"
> python -c "from imp import find_module; print find_module("pdb")"
> to find out where the file is, and then run python normally with the filename
> that gets printed by one of the above scripts. (With a Unix-style shell,
> backticks make that easier. Doesn't help on Windows though).
> The "-m" option aims to automate this process (using the latter 'find_module'
> approach in C code)
I'm not going to stop you from adding this, but I do think you're
overlooking the fact that if you need this a lot, it's trivial to
write a tiny Python script that takes the place of "python -m", and
putting that python script in your PATH. Something like:
import sys, imp
fn = imp.find_module(sys.argv)
sys.argv = fn
seems do the trick (though it could use nicer error handling).
Wouldn't it be easier to add *this* to the Tools/scripts directory
(and the list of scripts that are installed by "make install" or the
Windows equivalent) than to burden the Python interpreter with C code
to do the same? Why does every handy thing that anyone ever thought of
have to be a Python command line option?
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev