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

Alex A. Naanou alex.nanou at gmail.com
Mon Sep 27 15:19:13 CEST 2004


---------- Forwarded message ----------
From: Alex A. Naanou <alex.nanou at gmail.com>
Date: Mon, 27 Sep 2004 17:18:20 +0400
Subject: Re: [Python-Dev] a simpler way to invoke pydoc, pdb, unittest, etc
To: dima at hlabs.spb.ru

On Mon, 27 Sep 2004 14:12:32 +0000, Dmitry Vasiliev <lists at hlabs.spb.ru> wrote:
> 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
>

this might not be good (IMHO), as:
1) this makes an implicit import (from the point of view of the
code... (imports from outside the code that the code uses))...
2) does does not solve the problem at hand, as when a module is
imported its __name__ is no longer "__main__" thus its commandline
handler will not start...

--
Alex.




-- 
Alex.


More information about the Python-Dev mailing list