[docs] Comparison error?
Georg Brandl
georg at python.org
Sat Sep 17 20:23:30 CEST 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 15.09.2011 16:30, schrieb Reich, Edwin:
> While reading through the "New-style and classic classes" section of the
> documentation http://docs.python.org/reference/datamodel.html#newstyle I
> found what I believe to be an error.
>
> The statement regarding rich comparison methods reads: There are no
> swapped-argument versions of these methods (to be used when the left
> argument does not support the operation but the right argument does);
> rather, __lt__() and __gt__() are each other’s reflection, __le__() and
> __ge__() are each other’s reflection, and __eq__() and __ne__() are their
> own reflection.
>
>
> The error is that __lt__() and __ge__() should be the reflection of each
> other and __le__() and __gt__() should be the reflection of each other.
> Hopefully, this is an error only in the documentation and not the
> language. I haven't tested the language to verify that it doesn't work as
> documented.
Hi Edwin,
I think both docs and code are correct: when you do
A() < B()
where the B class has rich comparison methods defined, and A hasn't, then
this is equivalent to asking if
B() > A()
and not
B() >= A()
Note that "reflection" in this case means the order of operands. There is
no negation inveolved.
cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
iEYEARECAAYFAk505aEACgkQN9GcIYhpnLDyhQCfa2ie295zZ7eMnqx2HWJHGPGm
DxkAoK5w9yFmiyEjWz1ktq6+3128pbxN
=qGCw
-----END PGP SIGNATURE-----
More information about the docs
mailing list