[Python-ideas] Commas [was Re: except expression]
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Feb 18 06:19:28 CET 2014
Alexander Belopolsky wrote:
> Funny: less than an hour ago, I paused when writing a lambda to return a
> tuple. I conservatively put parentheses around the tuple and did not
> bother to check if they are required. Now I know that they are.
It's even more confusing when you consider that
you can write
lambda x, y: x + y, 2
and the first comma doesn't break up the lambda,
but the second one does!
With oddities like this already in the language,
I don't think we need to worry too much about the
corner cases. People are always free to insert parens
to make things clearer. E.g. I would probably write
the above as
(lambda (x, y): x + y), 2
--
Greg
More information about the Python-ideas
mailing list