Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #36 from paulie-g/master
Browse files Browse the repository at this point in the history
Document @with_cmp's effect on object hashes
  • Loading branch information
hynek committed Jun 28, 2015
2 parents 4040b6e + 4440f49 commit 0696048
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions characteristic.py
Expand Up @@ -249,9 +249,12 @@ def _ensure_attributes(attrs, defaults):

def with_cmp(attrs):
"""
A class decorator that adds comparison methods based on *attrs*.
A class decorator that adds comparison methods and a hashing method based
on *attrs*.
For that, each class is treated like a ``tuple`` of the values of *attrs*.
For that, each class is treated like a ``tuple`` of the values of *attrs*,
so objectA == objectB -> True and objectA.__hash__() == objectB.__hash() ->
True iff objectA's tuple of *attrs* == objectB's tuple of *attrs*.
But only instances of *identical* classes are compared!
:param attrs: Attributes to work with.
Expand Down

0 comments on commit 0696048

Please sign in to comment.