How can you use a class 1's method in another class 2. Class 2 does not inherit class 1.
Jump to Post
One way to use class 1's methods in class 2 is to have a class 2 object aggregate a class 1 instance. It is a standard pattern in OOP, called composition, which is often used as an alternative to inheritance
class Class1(object): def method(self): print(self) class Class2(object): …
All 4 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.