Compare object instances for equality by their attributes

Compare object instances for equality by their attributes

The Python Oracle

1 год назад

18 Просмотров

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops

--

Chapters
00:00 Question
00:49 Accepted answer (Score 466)
02:37 Answer 2 (Score 53)
03:07 Answer 3 (Score 21)
07:26 Answer 4 (Score 11)
07:59 Thank you

--

Full question
https://stackoverflow.com/questions/1227121/compare-object-instances-for-equality-by-their-attributes

Accepted answer links:
[__eq__]: https://docs.python.org/3/reference/datamodel.html#object.__eq__
[__hash__]: https://docs.python.org/3/reference/datamodel.html#object.__hash__
[__cmp__]: https://portingguide.readthedocs.io/en/latest/comparisons.html#rich-comparisons
[__ne__]: https://docs.python.org/2/reference/datamodel.html#object.__ne__

Answer 2 links:
[rich comparison operators]: https://docs.python.org/2.7/reference/datamodel.html#object.__lt__

Answer 3 links:
[pickle]: https://stackoverflow.com/questions/7501577/cpickle-different-results-pickling-the-same-object

Answer 4 links:
[Dataclasses in Python 3.7]: https://docs.python.org/3.7/library/dataclasses.html
[backport for Dataclasses]: https://pypi.org/project/dataclasses/

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/licensing

--

Tags
#python #equality

#avk47

Тэги:

#avk47 #equality #python
Ссылки и html тэги не поддерживаются


Комментарии: