A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-June/153971.html below:

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

[Python-Dev] About [].append == [].append [Python-Dev] About [].append == [].appendSerhiy Storchaka storchaka at gmail.com
Thu Jun 21 15:53:02 EDT 2018
21.06.18 14:25, Jeroen Demeyer пише:
> 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

I think this is a bug. These bound methods can't be equal because they 
have different side effect.

The use case for using "is" for __self__ is described by the OP of 
issue1617161. I don't know use cases for using "==".

There is a related problem of hashing. Currently
bound methods are not hashable if __self__ is not hashable. This makes 
impossible using them as dict keys.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4