[Python-Dev] a simpler way to invoke pydoc, pdb, unittest, etc

ncoghlan at iinet.net.au ncoghlan at iinet.net.au
Mon Sep 27 16:32:36 CEST 2004


Quoting Anthony Baxter <anthony at interlink.com.au>:

> 
> > +1 on the -m command-line variation, with the following change:
> > 
> >   I'd like Python to import the module and then run it's main function.
> > 
> > I've been meaning to suggest smething like this myself.
> 
> I'd prefer it import the module, with __name__ == "__main__",
> because it's compatible with what we do now for a module that's
> also a script. But I like the idea, nonetheless.
> 
> Question: should python -m foo.bar.baz work? I'd say "yes".

I was curious how hard this would be to implement. Minus Andrew's addition, the
answer is "Not very". So those who are interested in the idea might want to take
a look at SF Patch # 1035498.

The patch tries to make "./python -m pdb" mean the same thing as "./python
Lib/pdb.py" on a development build. (I use that example, because I have only a
very vague idea of where the pdb script ends up for an installed version of
Python - which is why I think this option would be very useful!)

Cheers,
Nick.



More information about the Python-Dev mailing list