Referencing `self` In `__old__` In PyContract Constraints
I'm working on writing some constraints for a class method using PyContract (not PyContracts). As a postcondition, I'd like to ensure that the memory address of the instance hasn't
Solution 1:
This seems to fix it:
class Individual:
def append(self, chrom):
"""
post[self]:
__old__.self is self
len(__old__.self.chromosomes)+1 == len(self.chromosomes)
self.chromosomes[-1] == chrom
"""
self.chromosomes.append(chrom)
Post a Comment for "Referencing `self` In `__old__` In PyContract Constraints"