[Python-ideas] Modern language design survey for "assign and compare" statements
Juancarlo Añez
apalala at gmail.com
Mon May 21 08:22:46 EDT 2018
> while ((v = get_something()) != INCONVENIENT_SENTINEL)
> do_something(v);
>
The current pattern in Python would be something like:
v = get_something()
while v != INCONVENIENT_SENTINEL:
do_something(v)
v = get_something()
With "as" allowed in "while", they pattern might be:
while get_something() as v:
if v == INCONVENIENT_SENTINEL:
break
do_something(v)
The discussion isn't over, so it could also be:
while (get_something() as v) != INCONVENIENT_SENTINEL:
do_something(v)
Cheers,
--
Juancarlo *Añez*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180521/20c76a8d/attachment.html>
More information about the Python-ideas
mailing list