[Python-ideas] Consider having collections.abc.Sequence implement __eq__ and __ne__

Neil Girdhar mistersheik at gmail.com
Fri Aug 19 07:11:58 EDT 2016


I mean zip(self, other)

On Friday, August 19, 2016 at 6:46:57 AM UTC-4, Neil Girdhar wrote:
>
> Both Mapping and Set provide __eq__ and __ne__.  I was wondering why not 
> have Sequence do the same?
>
>
> class Sequence(Sized, Reversible, Container):
>
>     def __eq__(self, other):
>         if not isinstance(other, Sequence):
>             return NotImplemented
>         if len(self) != len(other):
>             return False
>         for a, b in self, other:
>             if a != b:
>                 return False
>         return True
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160819/2793161e/attachment-0001.html>


More information about the Python-ideas mailing list