pydoc script.py vs. pydoc scriptpy

Discussion in 'Python' started by BartlebyScrivener, Oct 20, 2007.

  1. 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
    BartlebyScrivener, Oct 20, 2007
    #1
    1. Advertising

  2. BartlebyScrivener

    Stargaming Guest

    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
    Stargaming, Oct 22, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Hansen

    Re: Securing PyDoc and CGIHTTPserver

    Peter Hansen, Jul 10, 2003, in forum: Python
    Replies:
    7
    Views:
    419
    Peter Hansen
    Jul 15, 2003
  2. Shane Hathaway

    Re: Securing PyDoc and CGIHTTPserver

    Shane Hathaway, Jul 10, 2003, in forum: Python
    Replies:
    1
    Views:
    370
    Shane Hathaway
    Jul 11, 2003
  3. Greg Kuperberg

    How does pydoc parse code?

    Greg Kuperberg, Oct 16, 2003, in forum: Python
    Replies:
    2
    Views:
    787
    Bengt Richter
    Oct 18, 2003
  4. Rajat
    Replies:
    3
    Views:
    680
    Jorgen Grahn
    Jan 8, 2010
  5. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    544
    Jan Kaliszewski
    Jan 7, 2010
Loading...

Share This Page