On 24/01/2011 21:51, Alan wrote:
Why do function objects compare in this way to numbers?
Thanks,
Alan Isaac


def f(): return
...
f>5
True

In Python 2 any object can be compared in this way to any other. The
result is arbitrary but consistent.

In Python 3 that has changed because in practice it's more trouble than
it's worth:

>>> def f(): return

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

It's usually a good sign that there's a bug somewhere.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to