while true: !!!
pbjorn at uswest.net
Tue Dec 19 09:39:50 EST 2000
Steve Lamb wrote:
> On Mon, 18 Dec 2000 07:38:52 -0700, Bjorn Pettersen <pbjorn at uswest.net> wrote:
> > for line in f.readlines():
> > ...
> >has the potential of crashing your machine with an out-of-memory error if you
> >don't know the sizes of files you're operating on.
> ...wastes memory.
Well, if you have it, and use it, you're hardly wasting it <wink>.
> >So, the status quo is that because the straight-forward way of doing it is
> >too slow, we're all using an optimized idiom that while easy to understand if
> >coming from a CS background, doesn't model what you're doing (at least not
> >until you've programmed enough Python that reading a file seems like an
> >endless loop <wink>).
> Or doing it in the 2-3 other languages I know of which use while in the
> exact same manner. I'm sure if we took a pole of the computer languages known
> here you'd find that it is pretty much a standard across many languages, not
> just Python.
Thank you for restating what I said: coming from a CS background/other languages,
"while 1:" is quite understandable. I don't think this is necessarily an area
worth mimicking other languages though (especially since one of the main arguments
for adding += to the language was because it closer modelled the intended semantic
of the expression).
> Hell, if you want to grouse about readability in Python, why not attack
> some of the more obvious targets?
> [snip examples of else clauses on for and while loops]
So you're arguing that since Python is so unreadable in it's use of else clauses,
"while 1:" hardly matters? <wink>
ps: the only questions I have seen about "else on while" have indicated that
beginners expect the else clause to be executed if the condition fails the first
time (I could probably come up with a coherent argument for why that is the
"negative" of a loop <wink>)
pps: I did enjoy the "while 1: ... else: ..." construct ;-)
More information about the Python-list