do...while
Sean 'Shaleh' Perry
shalehperry at attbi.com
Thu Jun 20 13:42:56 EDT 2002
On 20-Jun-2002 Michael P. Soulier wrote:
> Greetings.
>
> How do you people handle the lack of a do...while in Python? I find that
> at times, I must initialize variables for a loop with identical code to the
> loop, which feels like a waste to me.
>
> ie.
>
> line = filehandle.readline()
> while len(line) > 5:
> line = filehandle.readline()
>
> A do...while here would be nice.
>
> Just curious.
>
while 1:
line = filehandle.readline()
if len(line) <= 5: break
....
....
is a typical way to implement it.
More information about the Python-list
mailing list