[Python-ideas] A PEP on introducing variables on 'if' and 'while'

Chris Angelico rosuav at gmail.com
Sun Jun 10 08:55:06 EDT 2018

On Sun, Jun 10, 2018 at 10:08 PM, Juancarlo Añez <apalala at gmail.com> wrote:
> There can be cases in which combining both syntaxes is useful:
> x = None
> while compute(x := v for v in next_series_value(x)) as comp:
>     ...
>     x = comp

Why not just:

while comp := compute(x := v for v in next_series_value(x)):

Why have two syntaxes, one of which is a shackled version of the
other? If we have :=, there's no point having as.


More information about the Python-ideas mailing list