Can you set parent class attributes using super()
in python 2.7? I would expect the following code to work, but it does not:
class A(object):
val_a = 1
class B(A):
val_b = 2
def set_a(self, val):
super(B,self).__class__.val_a = val
b = B()
b.set_a(3)
It gives the following error:
TypeError: can't set attributes of built-in/extension type 'super'
Is there a correct way to do this?