[Python-ideas] Modern language design survey for "assign and compare" statements
Rhodri James
rhodri at kynesim.co.uk
Mon May 21 07:05:40 EDT 2018
On 19/05/18 01:54, Mike Miller wrote:
> In short, extend the "if/elif", "while", and comprehension to:
>
> if pattern.search(data) as match:
> …
>
> while read_next_item() as value:
> …
Thanks for the analysis, but I'm afraid I must disagree with your
recommendation. It was the thought I first had when Chris came out with
his first draft of the PEP several months ago, but it's not enough to
cope with my usual use cases. What I normally want is the Python
equivalent of:
while ((v = get_something()) != INCONVENIENT_SENTINEL)
do_something(v);
The condition expression itself is not what I want to capture; I need a
subexpression, which the "as" syntax won't give me.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas
mailing list