Raise IndexError

This commit is contained in:
Thomas Krijnen
2017-08-02 16:05:56 +02:00
parent 29323e4f74
commit 5c7e7cab1a
@@ -80,6 +80,8 @@ class entity_instance(object):
self[self.wrapped_data.get_argument_index(key)] = value
def __getitem__(self, key):
if key < 0 or key >= len(self):
raise IndexError("Attribute index {} out of range for instance of type {}".format(key, self.is_a()))
return entity_instance.wrap_value(self.wrapped_data.get_argument(key))
def __setitem__(self, idx, value):