Pablo Galindo Salgado <[email protected]> added the comment:
I think this is correct because if you add a comma, indeed is valid syntax:
>>> sum,[i for i in [1, 2, 3] if i%2==0]
(<built-in function sum>, [2])
Here the problem is that you are mentally mapping the construct to sum(...)
where the parens are substituted with brackets, which is not what the parser
sees, the parser sees two expressions glued together like
>> f() g()
File "<stdin>", line 1
f() g()
^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
and it surrounds the whole expression.
Do you have an idea on what you would prefer here? Otherwise, I suggest to
close as "not a bug".
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45801>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com