How to use pydoc?

P

Peter Otten

import pydoc
import sys
sys.version '2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]'
pydoc sys SyntaxError: invalid syntax

The documentation for pydoc says:
"Run "pydoc <name>" to show documentation on something."

What am I missing?

In the interpreter, just do

if you didn't already import the module.

What you tried is what you would do on the command line. I'm not sure it
works on windows, though, but

python -m pydoc sys

Should work on both windows and unix.

Peter
 
N

newsposter

Thanks for replying Peter, but none of your suggestions are working.

S:\projects\C2PC\src>python -m
Unknown option: -m
usage: python [option] ... [-c cmd | file | -] [arg] ...

I should also be able to run 'pydoc -g' to start a webserver.

I guess I will have to write the author of pydoc for an answer.

Chris
 
K

Kent Johnson

Thanks for replying Peter, but none of your suggestions are working.

S:\projects\C2PC\src>python -m
Unknown option: -m
usage: python [option] ... [-c cmd | file | -] [arg] ...

The -m option was added in Python 2.4, you must have an older version (though your OP
shows 2.4.2...). Try
python c:\python23\Lib\pydoc.py sys

or whatever the correct path is to python on your system.
I should also be able to run 'pydoc -g' to start a webserver.

python c:\python23\Lib\pydoc.py -g

or Start / Programs / Python 2.x / Module docs

Kent
 
D

dvm1981

import pydoc
import sys
sys.version '2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]'
pydoc sys SyntaxError: invalid syntax

The documentation for pydoc says:
"Run "pydoc <name>" to show documentation on something."

What am I missing?

Thanks!
Chris

On a GNU/Linux distribution you can run in a shell the command 'pydoc -g'.
This start a little interface that start a little webserver, so it open an
webbrowser and go to a page where you easy find info about modules etc...
 
P

Peter Otten

Thanks for replying Peter, but none of your suggestions are working.

S:\projects\C2PC\src>python -m
Unknown option: -m
usage: python [option] ... [-c cmd | file | -] [arg] ...

I should also be able to run 'pydoc -g' to start a webserver.

Do you have multiple versions of Python on your computer?

The -m option only works with python2.4, so it seems Windows invoked a wrong
(older) Python version.

For older versions you can do

python c:\path\to\pydoc.py -g

Alternatively you can make sure you pick the right interpreter explicitly:

c:\path\to\python2.4\python.exe -m pydoc -g
I guess I will have to write the author of pydoc for an answer.

If none of the above works, be patient. Someone with a fresher Python on
Windows experience will eventually speak up :)

Peter
 
F

Fredrik Lundh

Thanks for replying Peter, but none of your suggestions are working.

S:\projects\C2PC\src>python -m
Unknown option: -m
usage: python [option] ... [-c cmd | file | -] [arg] ...

I should also be able to run 'pydoc -g' to start a webserver.

I guess I will have to write the author of pydoc for an answer.

if you look in the Python menu in the program menu, you'll find a
"module docs" entry that starts pydoc for you.

</F>
 
S

SPE - Stani's Python Editor

If it's just about displaying pydoc pages... SPE Python IDE has pydoc
built in. Just open any file and click on the pydoc tab, next to the
uml tab. Then you see the python documentation of that script, which is
generated on the fly, If you want to see documentation about the sys
module, just click in the upper right corner on the index link.

This works on Windows, Linux and Mac without a pain.

Stani
 
N

newsposter

Thanks Peter. I do have two versions, with the older one existing for
compatibility with another application. Option -m works with 2.42. I
neglected to check this when I ran from the command-line.

Thanks,
Chris
 
N

newsposter

Thanks! Yes, it brings up a documentation server, and serves up some
nicely formatted documentation. Learning learning...
-Chris
 

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,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top