I have a function in a class that needs to be called several times in various other functions. It also has to be called independently. I'm getting this error: NameError: name 'function_i_use_often_within_others' is not defined
Is there a way a function can inherit other functions without having to nest them in each function that needs that action? See the sample code below. I tried creating a separate class and having it inherit the methods.. It still faced the same problem.
class testcase:
def __init__(self,xpath):
self.xpath = xpath
def function_i_use_often_within_others(self):
print('DOING SOMETHING OFTEN')
def function2(self):
function_i_use_often_within_others()
print("Function2 doing something else")
def function3(self):
function_i_use_often_within_others()
print("Function3 doing something else")
trial = testcase('This is xpath')
trial.function_i_use_often_within_others()
trial.function2()
trial.function3()