[New-bugs-announce] [issue3803] Comparison operators - New rules undocumented in Python 3.0

Matt Giuca report at bugs.python.org
Mon Sep 8 08:49:30 CEST 2008


New submission from Matt Giuca <matt.giuca at gmail.com>:

I've noticed that in Python 3.0, the <, >, <= and >= operators now raise
a TypeError when comparing objects of different types, rather than
ordering them "consistently but arbitrarily". The documentation doesn't
yet reflect this behaviour.

The current documentation says:
"(This unusual definition of comparison was used to simplify the
definition of operations like sorting and the in and not in operators.
In the future, the comparison rules for objects of different types are
likely to change.)"

I assume this is the change it's warning us about.

Hence I propose this patch to reference/expressions.rst, which removes
the above quoted paragraph and describes the new TypeError-raising
behaviour. My text is as follows:

"The objects need not have the same type. If both are numbers, they are
converted to a common type. Otherwise, the == and != operators always
consider objects of different types to be unequal, while the <, >, >=
and <= operators raise a TypeError when comparing objects of different
types."

----------
assignee: georg.brandl
components: Documentation
files: expressions.patch
keywords: patch
messages: 72767
nosy: georg.brandl, mgiuca
severity: normal
status: open
title: Comparison operators - New rules undocumented in Python 3.0
versions: Python 3.0
Added file: http://bugs.python.org/file11421/expressions.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3803>
_______________________________________


More information about the New-bugs-announce mailing list