Looping [was Re: Python and the need for speed]
marko at pacujo.net
Tue Apr 18 02:33:27 EDT 2017
Christian Gollwitzer <auriocus at gmx.de>:
> Am 18.04.17 um 02:18 schrieb Ben Bacarisse:
>> Python opts for
>> while True:
>> c = sys.stdin.read(1)
>> if c != ' ': break
> This loop would be the archetypical do..while or repeat...until to me.
> c = sys.stdin.read(1)
> while c== ' '
No, the code continues. You want to do something with c, right?
> is the most clear to me - and in fact this "while True; do something;
> break" thingy is just an idiom to fake a do..while loop in Python. C
> does have it, for example, and it is way better like this than the
> abuse of assignment and comma operator in the condition.
I do use
do ... while
in my C code whenever a loop would end in a conditional break. I happens
exceedingly rarely, though.
More information about the Python-list