Thoughts on PEP315
Heather Coppersmith
me at privacy.net
Tue Sep 23 06:27:44 EDT 2003
On Tue, 23 Sep 2003 05:35:57 GMT,
Jordan Krushen <jordan at krushen.com> wrote:
> On Tue, 23 Sep 2003 06:08:06 +0100, Stephen Horne wrote:
>> for ever :
>> <statements>
>> break if <condition> :
> You could always hide something similar in a generator:
> def forever():
> while True: yield True
> for now in forever():
> print 'looping forever...'
> ...although I must admit, I don't really mind "while True:" that
> much.
Don't forget that values other than "True" are true, too
(shamelessly stolen from a previous post from Tim Peters):
# basic file iteration (which can be done in other ways, but
# simply demonstrates my point)
while "there is another line in the file":
nextlinefromfile = getnextlinefromfile( )
if not nextlinefromfile:
break
moresprocessing( )
# typical server-like endless loop
while "[heck] has not frozenover":
command = getnextcommand( )
actoncommand( command )
strings-are-true'ly yours,
Heather
--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli
More information about the Python-list
mailing list