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


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

Re: Python Basic Doubt

Started byChris Angelico <rosuav@gmail.com>
First post2013-08-11 02:32 +0100
Last post2013-08-11 02:32 +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: Python Basic Doubt Chris Angelico <rosuav@gmail.com> - 2013-08-11 02:32 +0100

#52342 — Re: Python Basic Doubt

FromChris Angelico <rosuav@gmail.com>
Date2013-08-11 02:32 +0100
SubjectRe: Python Basic Doubt
Message-ID<mailman.450.1376184743.1251.python-list@python.org>
On Sun, Aug 11, 2013 at 2:25 AM, Terry Reedy <tjreedy@udel.edu> wrote:
> On 8/10/2013 8:42 PM, Gary Herron wrote:
>
>> But for each of your examples, using "==" is equivalent to using "is".
>> Each of
>>      if something == None
>>      if device == _not passed
>>      if device != None
>> would all work as expected.  In none of those cases is "is" actually
>> needed.
>
>
> class EqualAll:
>     def __eq__(self, other): return True

That's a contrived example, of course, but it's easy to have a bug in
__eq__ that results in the same behaviour. I can't imagine any code
that would actually WANT that, unless you're trying to represent
Animal Farm.

class EqualAll:
    def __eq__(self, other):
        if (isinstance(other, pig): return 3   # Some are more equal than others
        return True

ChrisA

[toc] | [standalone]


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


csiph-web