On 3/7/07, Georg Brandl
Jim Jewett schrieb:
That said, I'm still not sure it would be worth the cost, because people might start trying to write
while (1,2,3)
and expecting an implicit iteration; the confusion to beginners *might* outweigh the benefits.
Hm, why would anyone write that because of the new "as" syntax?
It isn't always clear (particularly to a beginner, or someone coming from another programming language) when to use "while" and when to use "for". I've seen plenty of C code with for loops that don't increment a counter -- they could easily be while loops. I imagine getting into it somehow along the following lines; # OK, I want to go through the list. # I need a loop. "while" gives me a loop. while [1, 2, 3] as num: print num # wait, I don't really need the number for this, I just need to get this # stupid thing to loop. Maybe if I take out the "as"? while [1,2,3]: print "got in" Obviously, you can say that the right answer here is a for loop for num in [1, 2, 3]: ... but I'm not sure how hard it would be to explain to a new user. It may be that I'm still thinking pre-file-iterators, and newbies won't have a problem ... but I'm not confident of that. -jJ