Here's the faulty bit of my code:
class Room(object):
def __init__(self):
self.hotspots = []
self.image = []
self.item = []
def newhotspot(*args):
new = {'Name' : None,
'id' : None,
'rect' : None,
'Takeable' : None,
'Lookable' : None,
'Speakable' : None,
'Itemable' : None,
'Goable' : None}
for i in args:
new[i[0]] = i[1]
new['id'] = len(self.hotspots)
self.hotspots.append(new)
CityTrader = Room()
CityTrader.newhotspot(('Name', 'Trader'),
('Takeable', 'Yes'))
The goal is to have a dictionary with all the keys set to none but the ones specified. However, when I run it I get:
[...]line 85 in <module>
('Takeable', 'Yes'))
[...]line 44, in newhotspot
new[i[0]] = i[1]
TypeError : 'Room' object does not support indexing
Anyone knows why and how to solve this? It seems to work when it's not wrapped inside a class.