[Python-ideas] Commas [was Re: except expression]

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Feb 17 22:36:32 CET 2014


On Mon, Feb 17, 2014 at 4:07 PM, Steven D'Aprano <steve at pearwood.info>wrote:

> > Guess what these evaluate to :-)
> >
> > x = lambda y: y, 2
> > x = 2,
> > x = 1, 2,
> > x = {1:2,}
>
> With the exception of the first one, where I'm not only 90% confident, I
> don't think there is any difficulty with any of those.
>

Same here.

>
> The first makes x a tuple containing (function, 2).
>

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140217/68f15321/attachment.html>


More information about the Python-ideas mailing list