[Python-Dev] a simpler way to invoke pydoc, pdb, unittest, etc
Dmitry Vasiliev
lists at hlabs.spb.ru
Mon Sep 27 16:12:32 CEST 2004
Ilya Sandler wrote:
> A problem:
>
> a number of standard python modules come with a command line interfaces,
> e.g. pydoc.py, pdb.py , unittest.py, timeit.py, uu.py
> But it appears that there is no convenient out-of-the-box way to invoke
> these tools from command line...
>
> Basically one either has to write wrappers or to
> invoke them like this: python /usr/lib/python2.3/pdb.py
>
> Neither approach is convenient...
>
> Am I missing something obvious? If not, then would the following make
> sense?
>
> When a script specified from command line is not found and the script name
> does not end with py, treat the script as a module name and execute
> that module as __main__
>
> So
> python pdb
> would be equivalent to
> python /usr/lib/python2.3/pdb.py
>
> A possible variation of the same idea would be to have an explicit
> command line option -m (or -M). More typing, but less magic...
There is already has been some discussion about importing from command line:
http://mail.python.org/pipermail/python-dev/2003-December/041240.html
I suggested the following:
1. python -p package
Equivalent to:
import package
2. python -p package.zip
Equivalent to:
import sys
sys.path.insert(0, "package.zip")
import package
--
Dmitry Vasiliev (dima at hlabs.spb.ru)
http://hlabs.spb.ru
More information about the Python-Dev
mailing list