On Sat, Jul 4, 2020, at 12:30, Joao S. O. Bueno wrote: > As far as types are concerned, the `__eq__` should worry about it - > just Sequences that are > a subtype of other, or the other being a subtype of one, should be able > to compare equal > (As happens with lists and tuples as well: subclasses of both will > compare equal to base lists and tuples > with the same content.).
As will two different subclasses of list. Should we try to replicate this behavior as well (i.e. determine the the "base sequence type" somehow, so that two subclasses of the same one can be compared and others cannot)? This is something that we have to get right the first time; equality comparisons can't be made more permissive later since they simply return False rather than being an error... otherwise I might be advocating to "fix" list and tuple. > The code for that is on my first reply to Guido, above: > if not issubclass(type(other), type(self)) and not > issubclass(type(self), type(other)): > return False > > I am actually using that on the file that motivated me sending the > first e-mail here -as it > makes sense in that project. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/IICSIZM4ASSEGNMZW6D56HN4YKIPVSPM/ Code of Conduct: http://python.org/psf/codeofconduct/