Sep-23-2021, 12:31 PM
I know the meaning of Instantiation and Inheritance.
I can inherit a class and use it methods and attributes.
I also can instantiate a class and still can use the same methods and attributes !!
I am just wondering why there exists two solutions for the same problem.
is there any advantage of using one over the other (memory, speed, ..)
Inheritance:
I can inherit a class and use it methods and attributes.
I also can instantiate a class and still can use the same methods and attributes !!
I am just wondering why there exists two solutions for the same problem.
is there any advantage of using one over the other (memory, speed, ..)
Inheritance:
class A: # define your class A pass class B: # define your class B pass class C(A, B): # subclass of A and BInstantiation:
class Foo(): def __init__(self,x,y): print (x+y) f = Foo(3,4)