I have two classes one parent and other child.
class Parent(object):
def __init__(self):
#does something
def method_parent(self):
print "Parent"
class Child(Parent):
def __init__(self):
Parent.__init__(self)
def method_parent(self):
print "Child"
After inheriting the parent I want to modify Parent method method_parent
keeping the original functionality of that method and adding some extra lines of code to that method.
I know that I can create a new method like
def method_child(self):
self.method_parent()
#Add extra lines of code to perform something
But I want to use the original name of method. I can't copy the source for that method because, the method is from a C
module
what I want to achieve is something like this
def method_parent():
#do parent_method stuff
#do extra stuff
Is that even possible?