anticipation.txt

Download anticipation.txt

If you can't read please download the document

Upload: biplab-haldar

Post on 25-Sep-2015

217 views

Category:

Documents


0 download

DESCRIPTION

Python Code

TRANSCRIPT

from utilities import UtlDictList# Anticipation Base Classclass Anticipation: # list of experiences or interactions loa = UtlDictList() def __init__(self, name): self.name = name def __repr__(self): return '{}'.format(self.name) def __hash__(self): intStr = ''.join(x for x in self.name if x.isdigit()) return int(intStr) def __eq__(self, other): if isinstance(other, str): return self.name == other elif isinstance(other, Anticipation): return self.name == other.name else: return self.name == other def __gt__(self, other): if isinstance(other, str): return self.name > other elif isinstance(other, Anticipation): return self.name > other.name else: return self.name > other def __lt__(self, other): if isinstance(other, str): return self.name < other elif isinstance(other, Anticipation): return self.name < other.name else: return self.name < other def __add__(self, other): if isinstance(other, str): return self.name + other elif isinstance(other, Anticipation): return self.name + other.name else: return self.name + other def __radd__(self, other): if isinstance(other, str): return other + self.name elif isinstance(other, Anticipation): return other.name + self.name else: return other + self.name @property def filterItem(self): return self.name @classmethod def clear(cls): cls.loa.clear() @classmethod def add(cls, key, item): cls.loa.addItem(key, item) @classmethod def get(cls, key): item = cls.loa.getItem(key) if key in cls.loa else None return item