Changeset 12426 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 8 Jan 2015, 14:25:54 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/schoolgrades.py
r12424 r12426 29 29 30 30 31 #: A unique default value. 32 DEFAULT_VALUE = object() 33 34 31 35 class ResultEntry(grok.Model): 32 36 """A result entry contains a subject and a grade. … … 45 49 46 50 def __eq__(self, obj): 47 default = object() 48 result = [] 51 """Two ResultEntry objects are equal if their `subject` and 52 `grade` are equal. 53 """ 49 54 for name in ('subject', 'grade',): 50 result.append( 51 getattr(self, name) == getattr(obj, name, default)) 52 return False not in result 55 if getattr(self, name) != getattr(obj, name, DEFAULT_VALUE): 56 return False 57 return True 58 59 def __ne__(self, other): 60 """Two ResultEntries are not equal, if their equality test fails. 61 62 a != b <-> not(a == b). Python doc tell, that __ne__ should 63 also be rovided, whenever __eq__ is implemented. 64 """ 65 return not self.__eq__(other) 53 66 54 67 def to_string(self):
Note: See TracChangeset for help on using the changeset viewer.