while true: !!!

deadmeat root at [127.0.0.1]
Mon Dec 11 08:19:02 EST 2000


> >     count = 0
> >     while 1:
> >         lines = file.readlines(8192)
> >         if not lines: break
> >         count = count + len(lines)

I'm new to Python, but I use 'break' and 'continue' regularly in others.
originally i considered the practise evil, and not much better than GOTOs,
however as my programs started getting bigger and more reliable (ie. i
started checking for all error conditions :), if..then..else, while..do and
for blocks just became a enourmous mess. as irritating as GOTOisms are, it's
a lot neater to simply short circut the block when something occurs (eg. an
error) than intent an entire block due to one single (if, while, for, etc)
statement.

i suspect the problem will be even worse in python because indentation is
mandatory. then again, it uses try..except to catch errors, which helps cut
the if..then trees down to just one pair.






More information about the Python-list mailing list