Re: [Tutor] 'pydoc' is not recognized as an internal or external command, ...

2010-11-12 Thread R Johnson
Thank you to all who have responded.
I have a bit of an update that reflects some of these suggestions. I was able 
to 
snag some time from one of the more experienced engineers and here is what we 
found:

On my system (Windows 7) the path to the lib file is C:\Python26\lib and 
"pydoc.py" is in this folder. So, he had me run: 

  python -m pydoc raw_input 
at that prompt. Sure enough, this returned what looked like help information 
for 
raw_input.

And, when we he had me follow the trail: Start > Control Panel > System > 
Advanced Settings > Environment Variables Python26 was in the PATH.






From: Steven D'Aprano 
To: tutor@python.org
Sent: Fri, November 12, 2010 5:44:41 PM
Subject: Re: [Tutor] 'pydoc' is not recognized as an internal or external 
command, ...

R Johnson wrote:
> 'pydoc' is not recognized as an internal or external command, operable 
> program 
>or batch file.

This means that the program "pydoc" is not installed on your computer, or is 
installed somewhere where the operating system (I'm guessing you're using 
Windows?) can't find it.

Use the Find File command, and see if you can find something called "pydoc". 
You 
may need to call the full path to the program, e.g.:

C:\My Documents\path\to\program\pydoc raw_input

or you may need to install it :)

> So, I go back to the terminal and type: python
> Then I type: pydoc raw_input
> The computer spits back: File "", line1
>   pydoc raw_input
> SyntaxError: invalid syntax
> (There is a carrot symbol under the "t" of input.)

pydoc is an external tool made with Python, it is not a Python command you can 
run. However, Python does come with an internal tool that is nearly as 
powerful: 
help().

>From the Python prompt, type:

help(raw_input)

and Enter, and you will get something very close to what pydoc would have given 
you.



-- Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 'pydoc' is not recognized as an internal or external command, ...

2010-11-12 Thread Jerry Hill
On Fri, Nov 12, 2010 at 6:44 PM, Steven D'Aprano  wrote:
> Use the Find File command, and see if you can find something called "pydoc".
> You may need to call the full path to the program, e.g.:
>
> C:\My Documents\path\to\program\pydoc raw_input

On my windows PC, it's c:\Python31\Lib\pydoc.py

So, to do what the tutorial is suggesting, you would need to open a
command prompt (cmd.exe) and run:
c:\Python31\Lib\pydoc.py raw_input

Note: Since I have python 3.1 installed, that wouldn't actually work,
because python 3.1 no longer has a raw_input function -- it's been
renamed to just input.

If you want to be able to run pydoc.py without specifying the full
path every time, I could add C:\Python31\Lib to my PATH environment
variable.

-- 
Jerry
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 'pydoc' is not recognized as an internal or external command, ...

2010-11-12 Thread Steven D'Aprano

R Johnson wrote:
'pydoc' is not recognized as an internal or external command, operable program 
or batch file.


This means that the program "pydoc" is not installed on your computer, 
or is installed somewhere where the operating system (I'm guessing 
you're using Windows?) can't find it.


Use the Find File command, and see if you can find something called 
"pydoc". You may need to call the full path to the program, e.g.:


C:\My Documents\path\to\program\pydoc raw_input

or you may need to install it :)


So, I go back to the terminal and type: python
Then I type: pydoc raw_input
The computer spits back: 
File "", line1

  pydoc raw_input
SyntaxError: invalid syntax
(There is a carrot symbol under the "t" of input.)


pydoc is an external tool made with Python, it is not a Python command 
you can run. However, Python does come with an internal tool that is 
nearly as powerful: help().


From the Python prompt, type:

help(raw_input)

and Enter, and you will get something very close to what pydoc would 
have given you.




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 'pydoc' is not recognized as an internal or external command, ...

2010-11-12 Thread David Hutto
For what you're looking for you could use:
>>>help(raw_input)

In the python terminal,meaning type python first.

For pydoc on ubuntu in the command line,

 pydoc -p 1234

and then take your
browser to http://localhost:1234, you might need
to select the work offline mode.

On windows IIRC it's about the same. I can check
if you need it.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc?

2010-10-18 Thread Alan Gauld


"Alex Hall"  wrote


about a program called brlapi. I am on Windows. Can someone explain
what is going on here?


Hmm... I am relatively new to Python and have not found this pydoc.


Well, I don't know how this is supposed to work on Windows. On 
Linux,

you simply run

pydoc brlapi



pydoc lives in

C:\PythonXX\Tools\scripts

And the best way to run it is probably to use the GUI so cd to the 
folder and run


python pydocgui.pyw

Or create a shortcut to do the same...

Basically it will provide you with a prettified web version of the 
help() output!

For that reason I tend not to use it much... YMMV

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc?

2010-06-18 Thread Alan Gauld

"Andrew Martin"  wrote

Hey, everyone, I am new to programming and just downloaded Python 
2.6 onto
my windows vista laptop. I am attempting to follow 4.11 of the 
tutorial

I am trying to use pydoc to search through the
python libraries installed on my computer but keep getting an error
involving the $ symbol.

$ pydoc -g
SyntaxError: invalid syntax


OK, There are lots of problems hidden within this request.

First, you are on windows Vista and the $ sign is the Linux command
prompt. So you need to use a Windows command console which will
have a prompt that looks something like:

C:\WINDOWS>

And you dont type the $.
You will find that a lot of programmers prefer Linux to Windows and so
a lot of the documentation tends to be Linux focused. You can usually
find Windows equivalents but it takes a bit of extra thought or
research sometimes.

Get used to using the command console because a lot of programming
tasks are best done there. In programming, GUIs are not always a good
thing...

However the error you get looks like a Python error which implies
you are at the pyhon interpreter prompt (>>>). That is not the
right place to be typing pydoc. That needs to be at the OS command
prompt. However, the final problem is that pydoc is not set up to run
from the command prompt - at least not on my PC. So before you
could get that to work you would also need to add the Tools\scripts 
folder
to your path The lesson to be learned is that translating 
instructions

intended for Linux into Windows is non-trivial.

BTW. The easiest way to start a Windows command prompt - if you don't
have a shortcut on your desktop - is to go to Start->Run and type
CMD in the dialog. Then hit OK.
A black command window should appear.

You'll find more detailed instructions and links to some help
info in the "Getting Started" topic of my tutorial.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc?

2010-06-18 Thread Andrew Martin
On Fri, Jun 18, 2010 at 7:13 PM, Andrew Martin wrote:

> Alright I got it. Although i didn't end up doing any typing. All I did was
> go to start/module docs and then press open browser.
>
> Thanks again and next time i will supply more info with the question
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc?

2010-06-18 Thread Andrew Martin
Alright I got it. Although i didn't end up doing any typing. All I did was
go to start/module docs and then press open browser.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc?

2010-06-18 Thread Lowell Tackett

>From the virtual desk of Lowell Tackett  


--- On Fri, 6/18/10, Andrew Martin  wrote:

From: Andrew Martin 
Subject: [Tutor] pydoc?
To: tutor@python.org
Date: Friday, June 18, 2010, 1:53 PM

Hey, everyone, I am new to programming and just downloaded Python 2.6 
onto my windows vista laptop. I am attempting to follow 4.11 of the 
tutorial called "How
 to Think Like a Computer Scientist: Learning with Python v2nd Edition 
documentation" (http://openbookproject.net/thinkcs/python/english2e/ch04.html).
 However, I am having some trouble. I am trying to use pydoc to search through 
the python libraries installed on my computer but keep getting an error 
involving the $ symbol. 

$ pydoc -g
SyntaxError: invalid syntax



Can anyone help me out?

Thanks

You're getting awfully close.  Again, assuming that you are in python; at the 
prompt type:

 pydoc modules

which will list all the module names, but...it's more than one screen and you 
can't go backwards, so you lose the first half.  So, type (instead):

 pydoc modules > made-upfilename

and you will create an ascii file (with the name you gave it) containing all 
the pydoc names in it.  The easiest way to open that file is:

 less made-upfilename

"less" is a bash command that opens files for reading.  As you'll see, it will 
allow you to scroll forward in the file (space bar) or backwards, with the "b" 
key.  To close that file, just type a "q" for quit.  And while your at it, 
while at bash's ($) the command line, type in "man less" w/o the quotes (that 
stands for "manual for 'less'"), and begin learning how the bash commands work, 
and how you can access great info as to how they work.

Good luck.



  

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc?

2010-06-18 Thread bob gailer

On 6/18/2010 1:53 PM, Andrew Martin wrote:
Hey, everyone, I am new to programming and just downloaded Python 2.6 
onto my windows vista laptop. I am attempting to follow 4.11 of the 
tutorial called "How to Think Like a Computer Scientist: Learning with 
Python v2nd Edition documentation" 
(http://openbookproject.net/thinkcs/python/english2e/ch04.html). 
However, I am having some trouble. I am trying to use pydoc to search 
through the python libraries installed on my computer but keep getting 
an error involving the $ symbol.


$ pydoc -g
SyntaxError: invalid syntax


I make a guess - that you are typing $ pydoc -g at the Python 
Interpreter prompt (>>>)


The manual recommends typing it a the shell prompt. In which case the $ 
represents the prompt and you should just type pydoc -g.



--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc?

2010-06-18 Thread bob gailer

On 6/18/2010 1:53 PM, Andrew Martin wrote:
Hey, everyone, I am new to programming and just downloaded Python 2.6 
onto my windows vista laptop. I am attempting to follow 4.11 of the 
tutorial called "How to Think Like a Computer Scientist: Learning with 
Python v2nd Edition documentation" 
(http://openbookproject.net/thinkcs/python/english2e/ch04.html). 
However, I am having some trouble. I am trying to use pydoc to search 
through the python libraries installed on my computer but keep getting 
an error involving the $ symbol.


It is good that you keep getting it. Consistency is valuable.


$ pydoc -g
SyntaxError: invalid syntax


Where are you typing this?

Where did you get the idea that $ pydoc -g is a valid thing to do?

In what way does this relate to the tutorial?

What OS are you using?

Please learn to ask "good" questions - which in this case means to tell 
us a lot more about what you are doing.


Please also reply-all so a copy of your reply goes to the tutor list.

--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pydoc introspecting info via OptionParser?

2008-03-15 Thread Neal McBurnett
On Fri, Mar 14, 2008 at 10:43:08AM -0700, Neal McBurnett wrote:
> I'm trying to do nice clean documentation for a python script I run
> from the command-line, and I'd like pydoc or a similar program to
> document it well.  But I don't want to duplicate option information by
> putting it both in my docstring and in optparse.
> 
> I would think that pydoc might notice an OptionParser instance at the
> module level and show the options defined there, but it doesn't seem
> to.  Would it be hard to add to pydoc?  Do any other documentation
> programs do that?

For now I've instead put this quasi-template-tag in my docstring in
an appropriate place: %InsertOptionParserUsage%

and added this code to the module to incorporate the usage into the
docstring after it is defined:

# incorporate OptionParser usage documentation in our docstring
__doc__ = __doc__.replace("%InsertOptionParserUsage%\n", parser.format_help())

That gets me pretty close.  The biggest problem is that when pydoc
prints it, the usage statement starts with "Usage: pydoc [options]"
rather than "Usage: myprogram [options]".  I could set the
OptionParser "prog" option to override that, but I prefer that in real
life the program provide usage referencing sys.argv[0] rather than
hard-coding it, in case it gets deployed under a different name.

Comments?

Neal McBurnett http://mcburnett.org/neal/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PyDoc problem

2005-09-23 Thread Christian Meesters
Hi Paul,

works great and within a seond, if I just uncomment the scipy imports. 
This was easy, but without your help I still would stare at my screen 
and think it's hopeless.

Thanks,
Christian
On 23 Sep 2005, at 13:18, paul brian wrote:

> THis sounds like a recursive import, which frankly should not happen
> but perhaps pydoc imports differently to the standard. Or it is trying
> to document the entire scipy framework, rather than just your module
>
> try firstly moving the module alone to directory foo and ensuring you
> are calling only that module
>
>> pydoc -w mymodule
>
> Perhaps also try uncommenting imports at the top of the file (ie #
> import scipy) to see if that helps.
>
>
>
> On 9/23/05, Christian Meesters <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> PyDoc is working well, if invoked without flags on the modul in
>> question. But when I use it with '-w' to produce html-output, I get an
>> extremely long Traceback after a runtime of an hour or two. Here is a
>> short part from it:
>>
>>  Traceback (most recent call last):
>>   File "/usr/bin/pydoc", line 4, in ?
>>   pydoc.cli()
>>   File
>> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>> python2.3/pydoc.py", line 2117, in cli
>>   writedoc(arg)
>>   File
>> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>> python2.3/pydoc.py", line 1383, in writedoc
>>   page = html.page(describe(object), html.document(object, name))
>>   File
>> "/Users/maxwell/Packages/SciPy_complete-0.3.2/build/lib.darwin-7.7.0-
>> Power_Macintosh-2.3/scipy_base/ppimport.py", line 397, in
>> _scipy_pydoc_Doc_document
>>   File
>> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>> python2.3/pydoc.py", line 283, in document
>>   if inspect.ismodule(object): return self.docmodule(*args)
>>  
>>   File
>> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>> python2.3/repr.py", line 49, in repr_list
>>   s = s + self.repr1(x[i], level-1)
>>   File
>> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>> python2.3/pydoc.py", line 319, in repr1
>>   return self.escape(cram(stripid(repr(x)), self.maxother))
>>   File
>> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>> python2.3/pydoc.py", line 111, in stripid
>>   if re.search(pattern, repr(Exception)):
>>   File
>> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>> python2.3/sre.py", line 137, in search
>>   return _compile(pattern, flags).search(string)
>>  RuntimeError: maximum recursion depth exceeded
>>
>> What's going wrong? When I ask Pydoc to write html documentation for
>> other modules there is no problem at all. It just works fine. And this
>> traceback tell me nothing about my module, only about PyDoc. For it
>> matters: I'm stuck with Python2.3 for compatibility reasons in this
>> project and the module I'd like to see documented uses scipy and it is
>> not really a small module anymore (about 1000 lines, including
>> docstrings and comments).
>> Anybody an idea how I can force PyDoc to produce html output on this
>> module?
>>
>> TIA
>> Christian
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
> --
> --
> Paul Brian
> m. 07875 074 534
> t. 0208 352 1741
>

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PyDoc problem

2005-09-23 Thread Kent Johnson
Christian Meesters wrote:
> Hi,
> 
> PyDoc is working well, if invoked without flags on the modul in  
> question. But when I use it with '-w' to produce html-output, I get an  
> extremely long Traceback after a runtime of an hour or two. Here is a  
> short part from it:
> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/sre.py", line 137, in search
>   return _compile(pattern, flags).search(string)
>   RuntimeError: maximum recursion depth exceeded
> 
> What's going wrong? When I ask Pydoc to write html documentation for  
> other modules there is no problem at all. It just works fine. And this  
> traceback tell me nothing about my module, only about PyDoc. For it  
> matters: I'm stuck with Python2.3 for compatibility reasons in this  
> project and the module I'd like to see documented uses scipy and it is  
> not really a small module anymore (about 1000 lines, including  
> docstrings and comments).

Some re searches in Python 2.3 can cause stack overflow. It looks like you may 
be running in to that problem. It is fixed in Python 2.4; could you use 2.4 to 
run pydoc?

Here is the relevant section of the Python 2.4 release notes:
The re module is also no longer recursive, thanks to a massive amount of work 
by Gustavo Niemeyer. In a recursive regular expression engine, certain patterns 
result in a large amount of C stack space being consumed, and it was possible 
to overflow the stack. For example, if you matched a 3-byte string of "a" 
characters against the expression (a|b)+, one stack frame was consumed per 
character. Python 2.3 tried to check for stack overflow and raise a 
RuntimeError exception, but certain patterns could sidestep the checking and if 
you were unlucky Python could segfault. Python 2.4's regular expression engine 
can match this pattern without problems.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor