Re: [Python-Dev] About [].append == [].append

2018年6月21日 04:33:02 -0700

On 2018年6月21日 13:25:19 +0200
Jeroen Demeyer <[email protected]> wrote:
> Currently, we have:
> 
> >>> [].append == [].append 
> False
> 
> However, with a Python class:
> 
> >>> class List(list): 
> ... def append(self, x): super().append(x)
> >>> List().append == List().append 
> True
> 
> In the former case, __self__ is compared using "is" and in the latter 
> case, it is compared using "==".
> 
> I think that comparing using "==" is the right thing to do because "is" 
> is really an implementation detail.
Probably... though comparing bound methods doesn't sound terribly
useful, so I'm not sure how much of an issue this is in practice.
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to