Fixed bugs involving None types

This commit is contained in:
SimpleArt
2020-12-07 21:07:04 -05:00
parent 23803593fc
commit c19ef0d1be
3 changed files with 17 additions and 16 deletions

View File

@ -7,9 +7,14 @@ class Gene:
self.value = deepcopy(value)
def __eq__(self, gene):
"""Comparing two genes by their value."""
return self.value == gene.value
def __eq__(self, other_gene):
"""Comparing two genes by their value.
Returns False if either gene is None."""
if (self is None) or (other_gene is None):
return False
else:
return self.value == other_gene.value
def __repr__(self):