<
def checkIndex(key):
if not isinstance(key, (int, long)):
raise TypeError
if key<0:
raise IndexError
class ArithmeticSequence(object):
"""docstring for ArithmeticSequence"""
def __init__(self, start=0, step=1):
super(ArithmeticSequence, self).__init__()
self.start = start
self.step = step
self.changed = {}
def __getitem__(self, key):
checkIndex(key)
try:
return self.changed[key]
except KeyError, e:
return self.start + self.step*key
def __setitem__(self, key, value):
checkIndex(key)
self.changed[key] = value