I am Inheriting from multiple parent classes into a single class. What I am trying to do is make a situation of object data conflict.
I mean if two classes hold a variable with same name and different data, which data will be loaded by Python if that variable comes to picture?
what I did
>>> class pac:
... var=10
... var2=20
...
>>> class cac:
... var3=30
... var2=10
...
>>> pob=pac()
>>> cob=cac()
>>> pob.var
10
>>> pob.var2
20
>>> cob.var2
10
>>> cob.var3
30
>>> class newclass(pac,cac):
... def sum(self):
... sum=self.var+self.var2
... sum2=self.var2+self.var3
... print(sum)
... print(sum2)
...
30
50
>>> nob.var
10
>>> nob.var2
20
>>> nob.var3
30
>>>
It seems like var2 data will consider from parent class : pac instead of cac class.
What needs to be done to make Python consider data from cac instead of pac if same variable name existed with different data? Please do not suggest me to change order of inheritance.
Thank you.
var2incacfromnewclass?