Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51942
| Date | 2013-08-05 00:05 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Bug? ( () == [] ) != ( ().__eq__([]) ) |
| References | <51FED74E.6080003@markusrother.de> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.194.1375657550.1251.python-list@python.org> (permalink) |
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. """
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Bug? ( () == [] ) != ( ().__eq__([]) ) MRAB <python@mrabarnett.plus.com> - 2013-08-05 00:05 +0100
csiph-web