do ... while loop
Wesley C.
wesc at rocketmail.com
Tue Oct 19 19:57:54 EDT 1999
In article <380BFAF1.116FB21E at mincom.com>,
Martin Pool <martinp at mincom.com> wrote:
> Cliff Crawford wrote:
> > I always liked BEGIN...WHILE...REPEAT in Forth. I guess the Python
version
> > would look like:
> >
> > begin:
> > x=f.readline()
> > while x:
> > print x
> >
> > The point being, you check the condition in the middle of the loop,
instead
> > of at the beginning or the end.
>
> At least the structure of
>
> while 1:
> x = f.readline()
> if not x: break
> print x
>
> is the same. So it's really just a matter of whether we want a
larger,
> more specific syntax, or a smaller syntax that relies a little more on
> people using idioms.
>
> Martin
yep, and if you read between the lines, you'll note that:
while 1:
:
if blah-blah: break
... is just a structure that makes up for the lack of a
do-while loop. although "while 1:" doesn't look that
proper, it's a default way to entering a loop. Python's
for-loop is really a for-each rather than a pure looping
mechanism.
-wesley
------------------------------------------------------------------------
"A computer never does what you want... only what you tell it."
Wesley C. <wesc at rocketmail.com>
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list