Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:

The parser rejects this ambiguity and requires parentheses:
[
    xxx
    for item in collection
    if (xxx := mutator(item)) is not None
]

Example ambiguity:

>>> [x for item in "abcdefabc" if x := item.upper() not in "ABC"]
SyntaxError: invalid syntax
>>> [x for item in "abcdefabc" if (x := item.upper()) not in "ABC"]
['D', 'E', 'F']
>>> [x for item in "abcdefabc" if (x := item.upper() not in "ABC")]
[True, True, True]
>>>

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44223>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to