Is non-virtual inheritance possible in Python, or do I have to use composition?
I would like to call methods against an individual instance of the base class for each subclass rather than a single one for all subclasses.
Update Example:
- Class A has an list in it.
- Class B and C are sublasses of A
- B and C add things to A’s list.
- B and C’s items are both in a single list in a single A object.
- I want B and C to have there own A, and hence their own A.list.
In Python, there is no separate instance of a base class if the base class is inherited multiple times. I don’t believe it’s possible to achieve what you’re asking using inheritance. Composition should work fine though.
P.S. Your question is phrased in a rather cryptic manner (using C++ terminology for a purely Python question), but I think I understood it. If I didn’t, my apologies.