On 11 June 2018 at 04:35, Juancarlo Añez <apal...@gmail.com> wrote:

>
> As the PEP author, that's your job.
>>
>
> I started writing the PEP, and I found an interesting example:
>
>     if not (m := re.match(r'^(\d+)-(\d+)$', identifier):
>         raise ValueError('f{identifier} is not a valid identifier')
>     print(f'first part is {m.group(1)}')
>     print(f'first part is {m.group(2)}')
>
>
> That's fairly easy to understand, and not something that can be resolved
> with `as` if it's part of the `if` and `while` statement, rather than a
> different syntax for the `:=` semantics.
>

Yep, the "What about cases where you only want to capture part of the
conditional expression?" question is the rock on which every "only capture
the entire conditional expression" proposal has foundered.

PEP 572 arose from Chris deciding to take on the challenge of seriously
asking the question "Well, what if we *did* allow capturing of arbitrary
subexpressions with inline assignments?".

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to