[Tutor] question about for loops

2010-01-07 Thread Richard D. Moores
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' %

Re: [Tutor] question about for loops

2010-01-07 Thread Richard D. Moores
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

Re: [Tutor] question about for loops

2010-01-07 Thread taserian
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

Re: [Tutor] question about for loops

2010-01-07 Thread Eike Welk
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_

[Tutor] question about for loops

2010-01-07 Thread Richard D. Moores
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