[Chicago] Why is '' > 0 True?

John Cronan kyle at pbx.org
Tue Dec 8 14:45:40 EST 2015


IIRC, in the spec it says that objects of different types are compared by
their class names, alphabetized. The only reason it's required to be in the
spec at all is that hashes can have keys of any type, so you need some
well-defined ordering.

-JKC

On Tue, Dec 8, 2015 at 1:40 PM, Robare, Phillip (TEKSystems) <
proba at allstate.com> wrote:

> A bug in our code has been hunted down and at its core is the fact that in
> Python
>
>
>
> ‘’ > 0
>
>
>
> is True.  It is actually true for any string and any integer.
>
>
>
> My expectation would be that the string form of ‘>’ would coerce its right
> argument to something comparable to its left argument.  But
>
>
>
> ‘’ > str(0)
>
>
>
> is False.
>
>
>
> Obviously we should not be trying to order mixtures of strings and
> integers so the bug is fixed, but I am wondering why this works the way it
> does.  Can anyone enlighten me?
>
>
>
> Phil Robare
>
>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20151208/c0f1a63a/attachment.html>


More information about the Chicago mailing list