Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51942 > unrolled thread

Re: Bug? ( () == [] ) != ( ().__eq__([]) )

Started byMRAB <python@mrabarnett.plus.com>
First post2013-08-05 00:05 +0100
Last post2013-08-05 00:05 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Bug? ( () == [] ) != ( ().__eq__([]) ) MRAB <python@mrabarnett.plus.com> - 2013-08-05 00:05 +0100

#51942 — Re: Bug? ( () == [] ) != ( ().__eq__([]) )

FromMRAB <python@mrabarnett.plus.com>
Date2013-08-05 00:05 +0100
SubjectRe: Bug? ( () == [] ) != ( ().__eq__([]) )
Message-ID<mailman.194.1375657550.1251.python-list@python.org>
On 04/08/2013 23:35, Markus Rother wrote:
> Hello,
>
> The following behaviour seen in 3.2 seems very strange to me:
>
> As expected:
>   >>> () == []
> False
>
> However:
>   >>> ().__eq__([])
> NotImplemented
>   >>> [].__eq__(())
> NotImplemented
>
> And:
>   >>> bool(NotImplemented)
> True
>
> Hence:
>   >>> bool(().__eq__([]))
> True
>   >>> ( () == [] ) != ( ().__eq__([]) )
> True
>
> How/why can this be intended?
>
The docs say:

"""NotImplemented
This type has a single value. There is a single object with this value. 
This object is accessed through the built-in name NotImplemented. 
Numeric methods and rich comparison methods may return this value if 
they do not implement the operation for the operands provided. (The 
interpreter will then try the reflected operation, or some other 
fallback, depending on the operator.) Its truth value is true.
"""

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web