Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 7 - pydoc from cmd

Tags:

python

pydoc

Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes.

Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was always what I wanted. This book has really spoken to me. That being said, I'm having a serious issue with pydoc from the command. I've got all the directories in c:/python26 in my system path and I can execute pydoc from the command line just fine regardless of pwd - but it accepts no arguments. Doesn't matter what I type, I just get the standard pydoc output telling me the acceptable arguments.

Any ideas? For what it's worth, I installed ActivePython as per Zed's suggestion.

C:\Users\Chevee>pydoc file
pydoc - the Python documentation tool

pydoc.py <name> ...
    Show text documentation on something.  <name> may be the name of a
    Python keyword, topic, function, module, or package, or a dotted
    reference to a class or function within a module or module in a
    package.  If <name> contains a '\', it is used as the path to a
    Python source file to document. If name is 'keywords', 'topics',
    or 'modules', a listing of these things is displayed.

pydoc.py -k <keyword>
    Search for a keyword in the synopsis lines of all available modules.

pydoc.py -p <port>
    Start an HTTP server on the given port on the local machine.

pydoc.py -g
    Pop up a graphical interface for finding and serving documentation.

pydoc.py -w <name> ...
    Write out the HTML documentation for a module to a file in the current
    directory.  If <name> contains a '\', it is treated as a filename; if
    it names a directory, documentation is written for all the contents.


C:\Users\Chevee>

EDIT: New information, pydoc works just fine in PowerShell. As a linux user, I have no idea why I'm trying to use cmd anyways--but I'd still love to figure out what's up with pydoc and cmd.

EDIT 2: More new information. In cmd...

c:\>python c:/python26/lib/pydoc.py file

...works just fine. Everything works just fine with just pydoc in PowerShell without me worrying about pwd, or extensions or paths.

like image 269
Random_Person Avatar asked Jan 22 '23 03:01

Random_Person


2 Answers

In Windows Powershell use: python -m pydoc

Examples:

python -m pydoc open

python -m pydoc raw_input

python -m pydoc argv

like image 137
mcmxl Avatar answered Jan 23 '23 16:01

mcmxl


When you type the name of a file at the windows command prompt, cmd can check the windows registry for the default file association, and use that program to open it. So if the Inkscape installer associated .py files with its own version of python, cmd might preferentially run that and ignore the PATH entirely. See this question.

like image 39
Josh Avatar answered Jan 23 '23 16:01

Josh