Say I have a class A:
class A:
list_attribute = ['foo', 'bar']
dict_attribute = {'foo': 'bar'}
A is extended by B, and in B I want to add elements to list_attribute
in the declaration of the class, it is pretty easy
class B(A):
list_attribute = A.list_attribute + ['foobar', 'barfoo']
My question is, how can I add elements to the dict_attribute
the same way I did for the list_attribute
(in the attribute definition, and not in the __init__
), since dicts don't support the +
operator ?
Thanks in advance and have a great day!