> Syntax:
> fwhile X in ListY and conditionZ:
There is precedent in Algol 68:
for i from 0 to n while safe(i) do .. od
which would also make a python proposal that needs no new key words:
for i in range(n) while safe(i): ..
The benefit of the syntax would be to concentrate the code
expressing the domain of the loop rather than have it in separate locations.
Not a big win in my opinion.
Neil
Neil,
I disagree. The problem IMO is that python 'for's are a different kind of 'for'
in that they have no explicit indexing and no explicit range test; just a list
which has elements drawn from it. This is amazingly
powerful and concise. Unfortunately, the "breaks are just gotos" community
often ruins this conciseness by going to 'while' or itertools (or worse) to
avoid adding a break to a 'for' which needs to be terminated early.
I think suggestions like yours and Fabio's are good ones. If 'for' has an
'else', why not a 'while'?
FWIW, I can sympathize with the 'no breaks or continues' notion, at least
largely so. That said, I have used gotos sparingly in C. The problem is that
applying the no-breaks notion to the python 'for' is problematic because as I
said earlier, the python 'for' is a special kind of 'for'. Maybe Guido needs
to be seen in public hugging a break statement..... :)
--
http://mail.python.org/mailman/listinfo/python-list