why are functions greater than numbers?

Benjamin Kaplan benjamin.kaplan at case.edu
Mon Jan 24 17:36:44 EST 2011


On Jan 24, 2011 5:31 PM, "Alan" <alan.isaac at gmail.com> wrote:
>
> Why do function objects compare in this way to numbers?
> Thanks,
> Alan Isaac
>
>
> >>> def f(): return
> ...
> >>> f>5
> True
>

Python 2 returned an arbitrary but consistent ordering for almost all
comparisons, just in case you were doing something weird like sorting a list
with mixed types. Python 3 will throw an exception if you try doing
something silly like compare a function to a number.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110124/2cc19236/attachment-0001.html>


More information about the Python-list mailing list