Why is lambda allowed as a key in a dict?

Vito De Tullio zak.mc.kraken at libero.it
Tue Mar 10 11:00:18 EDT 2009


MRAB wrote:

>  >>> (lambda arg: arg) == (lambda arg: arg)
> False

curious...
I somehow thinked that, whereas

>>> (lambda: 0) is (lambda: 0)
should be False (obviously)

>>> (lambda: 0) == (lambda: 0)
could be True... maybe because `{} == {} and {} is not {}` (also for [])

-- 
By ZeD




More information about the Python-list mailing list