I would like inherit a 'submethod' of a method in python. Could somebody help me to figure out how to do this please ?
Example of what I want to do :
class A(object):
def method(self, val):
def submethod():
return "Submethod action"
if not val:
return submethod()
return "Method action"
a = A()
class B(A):
def method(self, val):
#inherit submethod ?
def submethod():
return "Another submethod action"
return super(B,self).method(val)
b = B()
print "A : "
print a.method(True)
>> Method action
print a.method(False)
>> Submethod action
print "B : "
print b.method(True)
>> Method Action
print b.method(False)
Actual answer :
>> Submethod Action
**Wanted answer :
>> Another submethod action**
Kind regards,
Quentin