[docs] [issue11425] Cleanup sample codes in tutorial.

Raymond Hettinger report at bugs.python.org
Mon Mar 7 08:14:08 CET 2011

Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

Sorry, but I think many of these changes should not be made.

Sometime the tight spacing is used for visual grouping.  The following look fine and should not be changed because adding spaces around the + or * operator makes the whole sentence harder to mentally parse correctly:

   sum(x*y for x,y in zip(xvec, yvec))
   a, b = b, a+b

Also, it is perfectly correct to use:
   raise StopIteration
We use the parentheses when there is an argument:
   raise KeyError('key not found: {!r}'.format(k))

Sometimes one-liners are okay in the interactive mode for quick filter functions and whatnot.  Spreading them out with '...' lines makes the example harder to follow and expands the set-up part of the example rather than the part being explained.

It's perfectly valid to use x * x * x instead of x**3 in an example of how to use map.  We want the example to be as simple as possible.  

Also, the interactive prompt examples should be left as-is.  They communicate the free-form nature of experimentation at the prompt.

nosy: +rhettinger
resolution:  -> rejected
status: open -> closed

Python tracker <report at bugs.python.org>

More information about the docs mailing list