PEP-0315--Enhanced While Loop: An idea for an alternative syntax

John Roth newsgroups at jhrothjr.com
Wed Feb 18 06:45:32 EST 2004


"Paul Rubin" <http://phr.cx@NOSPAM.invalid> wrote in message
news:7xwu6khofz.fsf at ruckus.brouhaha.com...
> Erik Max Francis <max at alcyone.com> writes:
> > do:
> >     line = inputFile.readline()
> > while line:
> >     ...
> >     line = inputFile.readline()
>
> So it's yet another workaround for Python's lack of assignment
> expressions.  I like
>
>     while (line := inputFile.readline()):
>         ...
>
> a lot better.

It may go better in this instance, but assignment in expressions
does nothing for multi-line initialization/reinitialization constructs.

John Roth





More information about the Python-list mailing list