Why is lambda allowed as a key in a dict?

S Arrowsmith sion at paintbox.UUCP
Tue Mar 10 07:34:29 EDT 2009


Iain King  <iainking at gmail.com> wrote:
>Sort of tangenitally; is there any real difference between the outcome
>of the two following pieces of code?
>
>a = lambda x: x+2
>
>def a(x):
>    return x+2

a.__name__

As for why that matters, try a(None) and see which gives the more
informative traceback.

-- 
\S

   under construction




More information about the Python-list mailing list