I have no idea what is wrong or what causes the error:
AttributeError: 'dict' object attribute 'update' is read-only
on the following code:
map = []
point1back = {}
point1fwd = {}
point1back.update = {'nextHop':point1Fwd, 'direction':1, 'distance':0}
point1fwd.update = {'nextHop':point1Fwd, 'direction':3, 'distance':160}
map.append(point1back)
map.append(point1fwd)
The Python "AttributeError: 'dict' object has no attribute 'append'" occurs when we try to call the append() method on a dictionary. To solve the error, use bracket notation to add a key-value pair to a dict or make sure to call the append() method on a list.
The __dict__ in Python represents a dictionary or any mapping object that is used to store the attributes of the object. They are also known as mappingproxy objects. To put it simply, every object in Python has an attribute that is denoted by __dict__.
The Python "AttributeError: 'dict' object has no attribute 'iteritems'" occurs because the iteritems() method has been removed in Python 3. To solve the error, use the items() method, e.g. my_dict. items() , to get a view of the dictionary's items.
dict.update
is a method, not a variable you can assign a value to. Try this instead:
point1back.update({'nextHop':point1Fwd, 'direction':1, 'distance':0})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With