[Python-ideas] Immemorial desire for "do-while"-like construction
Jan Kaliszewski
zuo at chopin.edu.pl
Thu Jul 16 00:50:06 CEST 2009
Hello,
The issue has been coming back repeatedly:
How we could elegantly and pythonic'ly avoid repeating ourselves if
we need the control flow structure that e.g. in PASCAL has the form:
repeat
...
until CONDITION
In Python we must use while-loop in not very DRY (Don't Repeat
Yourself) manner:
SOME
ACTIONS
HERE
...
while CONDITION:
THE SAME
ACTIONS
AGAIN
...
(See also:
http://www.python.org/dev/peps/pep-0315/
http://mail.python.org/pipermail/python-dev/2006-February/060718.html
http://preview.tinyurl.com/nodgwt
)
Maybe here the simplest approach can lead us to the solution? I.e.:
repeat while CONDITION:
SOME
ACTIONS
HERE
...
In human language it'd mean: do ACTIONS once unconditionally, then
*repeat* them while the CONDITION is true.
Additional advantage is that probably for many people associate
'repeat' with such construction (from experience with other languages).
What do you think about the idea?
--
Jan Kaliszewski <zuo at chopin.edu.pl>
More information about the Python-ideas
mailing list