[Python-Dev] PEP 572, VF/B, and "Shark Jumping"

Mike Miller python-dev at mgmiller.net
Thu Jul 5 13:07:59 EDT 2018

On 2018-07-04 17:22, Chris Angelico wrote:
> - the "if expr as name:" syntax is able to handle only the tiniest
> proportion of cases, because many MANY situations require a condition
> after that. You can't write this, for instance:
> if f(x) as spam < 0:
>      print(spam)

The original use cases didn't ask for these compound conditions.  In fact many 
of the other threads this week are advising folks to break up an expression with 
compound conditions due to lack of readability.

The common cases described:

- compute value once in a comprehension
- loop and a half (reading file, socket)
- common regex match

More complex cases can be handled the old way.

 > Python uses "as NAME" for things that
 > are quite different from this, so it's confusing),

It's less confusing, and limited.  No one bats an eyelash after using "as" day 
after day in Python and SQL.

Good day,

More information about the Python-Dev mailing list