Python: Object does not support indexing
Python: Object does not support indexing
In order for the Brick
object to be indexable, you must implement the methods:
__getitem__
__setitem__
__delitem__
You dont need all of them, only the ones you use.
However, this seems like a case of self.bricks
being a brick instead of a list of bricks. A list of bricks is indexable; however, a brick itself is not unless you implement the methods above.
Check this for reference.
In order to be able to call self.bricks.bricksId[number]
when I needed:
def __getitem__(self,index):
return self.bricks.bricksId[index]
def __setitem__(self,index,value):
self.bricks.bricksId[index] = value