Python-by-example - new online guide to Python Standard Library

Terry Reedy tjreedy at udel.edu
Wed Apr 2 13:12:57 EDT 2008


"AK" <andrei.avk at gmail.com> wrote in message 
news:47f2d018$0$6517$4c368faf at roadrunner.com...

|| I'll be glad to hear comments/suggestions/etc:
|
| http://www.lightbird.net/py-by-example/

Using - as the example/return delimiter does not work.
If you do not want to substantially lengthen the document by going to

>>> sqrt(9)
3

then use Python's a comment symbol.

sqrt(9) # 3
-or-
sqrt(9) # returns 3 (but I think I prefer the first)

which clearly is not an arithmetic expression and which can be 
cut-and-pasted into the interactive interpreter.  This also works nicely 
for invalid examples.

sqrt(-9) # raises ValueError

Terry Jan Reedy










More information about the Python-list mailing list