pydoc script.py vs. pydoc scriptpy

B

BartlebyScrivener

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
 
S

Stargaming

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top