+ 1

Class that inherits an object of another class?

Hi! How to create a class that inherits an object from another class instead of a class itself, in Python? And how to make some features of that object shareable between the two (private/public/hidden etc.)? Any good example, please? Thank you so much! P.S. If not possible in Python then any other good way to do it in Python, please?

17th Aug 2019, 7:00 AM
Constantin Ghineț
Constantin Ghineț - avatar
3 Answers
+ 3
This is in the python course, (Inheritence), maybe what you are looking for: https://www.sololearn.com/learn/Python/2469/
17th Aug 2019, 11:25 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
I know that about inheritance but it is not what i want. Thank you!
17th Aug 2019, 6:17 PM
Constantin Ghineț
Constantin Ghineț - avatar
+ 1
You want to create object you want to "inherit" in constructor of that class or some setter method (aka depenedecy injection in some frameworks). Fancy name for this is composition
17th Aug 2019, 7:13 AM
Elva
Elva - avatar