why are functions greater than numbers?

Terry Reedy tjreedy at udel.edu
Mon Jan 24 18:13:45 EST 2011


On 1/24/2011 4:51 PM, Alan wrote:
> Why do function objects compare in this way to numbers?
> Thanks,
> Alan Isaac
>
>
>>>> def f(): return
> ...
>>>> f>5
> True

In 3.x
 >>> def f(): pass

 >>> f > 5
Traceback (most recent call last):
   File "<pyshell#39>", line 1, in <module>
     f > 5
TypeError: unorderable types: function() > int()

There is a historical explanation in many past posts and probably in the 
FAQ.

-- 
Terry Jan Reedy




More information about the Python-list mailing list