do ... while loop

Magnus L. Hetland mlh at idt.ntnu.no
Fri Oct 15 09:57:40 EDT 1999


thantos at brimstone.mecha (Alexander Williams) writes:

> On 14 Oct 1999 00:11:55 GMT, Joshua Marcus <josh at linc.cis.upenn.edu> wrote:
> >What is the %$*&@#!@ rationale behind not including a do...while control 
> >structure in Python?
> >
> >I know you can simply work around it, e.g:
> >
> >line = "foo"
> >while input != "":
> >    line = fp.readline()
> >    process(line)
> >
> >... but why must I do this every time?  Am I missing something?
> 
> Yes, you're missing three things:
> 
>   1) That initalization line should be "line = fp.readline()"

*And* you should have

  process(line)
  line = fp.readline()

But - why not use fileinput? <wink>

--

  Magnus          Echelon jamming noise:
  Lie             FBI CIA NSA Handgun Assault Bomb Drug Terrorism
  Hetland         Special Forces Delta Force AK47 Hillary Clinton 




More information about the Python-list mailing list