Message394235
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]
>>> |
|
Date |
User |
Action |
Args |
2021-05-24 07:27:35 | Dennis Sweeney | set | recipients:
+ Dennis Sweeney, socketpair, serhiy.storchaka, lys.nikolaou, pablogsal |
2021-05-24 07:27:35 | Dennis Sweeney | set | messageid: <1621841255.96.0.728631510349.issue44223@roundup.psfhosted.org> |
2021-05-24 07:27:35 | Dennis Sweeney | link | issue44223 messages |
2021-05-24 07:27:35 | Dennis Sweeney | create | |
|