This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dennis Sweeney
Recipients Dennis Sweeney, lys.nikolaou, pablogsal, serhiy.storchaka, socketpair
Date 2021-05-24.07:27:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621841255.96.0.728631510349.issue44223@roundup.psfhosted.org>
In-reply-to
Content
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]
>>>
History
Date User Action Args
2021-05-24 07:27:35Dennis Sweeneysetrecipients: + Dennis Sweeney, socketpair, serhiy.storchaka, lys.nikolaou, pablogsal
2021-05-24 07:27:35Dennis Sweeneysetmessageid: <1621841255.96.0.728631510349.issue44223@roundup.psfhosted.org>
2021-05-24 07:27:35Dennis Sweeneylinkissue44223 messages
2021-05-24 07:27:35Dennis Sweeneycreate