pydoc script.py vs. pydoc scriptpy

Stargaming stargaming at gmail.com
Mon Oct 22 11:21:45 EDT 2007


On Sat, 20 Oct 2007 15:02:26 +0000, BartlebyScrivener wrote:

> On Debian Etch, if ~/mypyscripts is in my bash PATH and also in
> PYTHONPATH, I get the following pydoc behaviors. Maybe this is
> intentional. I'm just checking to be sure I don't have something
> misconfigured in my environment.
> 
> If I have two scripts or modules  in ~/mypyscripts: one script.py and
> one scriptpy (no extension), and do:
> 
> $>pydoc script
> 
> I get the documentation strings for script.py.
> 
> However, if I do:
> 
> $>pydoc scriptpy
> 
> I get no doc strings, even if I am in the ~/mypyscripts directory, error
> message:
> "no Python documentation found for 'scriptpy'"
> 
> Instead I must do:
> 
> $>pydoc ~/mypyscripts/scriptpy
> 
> even though ~/mypyscripts is in both PATH and PYTHONPATH
> 
> Took me awhile to sort this out. Is this the way pydoc is supposed to
> work?
> 
> thanks,
> 
> rpd

>From the pydoc documentation:

    The argument to pydoc can be the name of a function, 
    module, or package, or a dotted reference to a class, 
    method, or function within a module or module in a 
    package. If the argument to pydoc looks like a path 
    (that is, it contains the path separator for your 
    operating system, such as a slash in Unix), and refers 
    to an existing Python source file, then documentation 
    is produced for that file.

Since `script` is a valid module name in your case, referencing 
script.py, pydoc uses this file. `scriptpy` is no valid module name and 
thus, does not work.

HTH,
Stargaming



More information about the Python-list mailing list