Comparison of functions

Peter Hansen peter at engcorp.com
Sat Jul 30 08:13:26 EDT 2005


Steven D'Aprano wrote:
> Playing around with comparisons of functions (don't ask), I discovered an
> interesting bit of unintuitive behaviour:
> 
>>>>(lambda y: y) < (lambda y: y)
> False
> 
> Do the comparison again and things become even more bizarre:
> 
>>>>(lambda y: y) < (lambda y: y)
> True
> 
>>>>(lambda y: y) < (lambda y: y)
> False
> 
> This behaviour should be easy for experienced Pythonisters to answer, but
> will probably confuse beginners greatly.

Beginners should not be comparing lambdas.

Neither should you. ;-)

-Peter



More information about the Python-list mailing list