On Thu, Jan 7, 2010 at 05:03, Alan Plum wrote:
> Variable unpacking works like this:
>
> points = [(0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2)]
>
> for (x,y) in points:
> print 'x: %d, y: %d' % (x, y)
>
> Without unpacking:
>
> for point in points:
> print 'x: %d, y: %d' %
Now I have a nice collection of examples, which to me are worth more
than the sometimes inscrutable docs.
My thanks to you three for taking the time to create the examples, and
accompany them with understandable explanations.
BTW I like Summerfield's book a lot, but he let me down on p.162.
Dick
On Thu, Jan 7, 2010 at 7:43 AM, Richard D. Moores wrote:
> On p. 162 of "Programming In Python", 2nd ed., by Summerfield, the
> section entitled "for Loops" begins:
>
> =
> for expression in iterable:
> for_suite
> else:
> else_suite
>
> The expressi
Hello Richard!
On Thursday January 7 2010 13:43:26 Richard D. Moores wrote:
> On p. 162 of "Programming In Python", 2nd ed., by Summerfield, the
> section entitled "for Loops" begins:
>
> =
> for expression in iterable:
> for_suite
> else:
> else_
On p. 162 of "Programming In Python", 2nd ed., by Summerfield, the
section entitled "for Loops" begins:
=
for expression in iterable:
for_suite
else:
else_suite
The expression is normally either a single variable or a sequence of
variables, usuall