There are two static methods in my class:
class my_class():
def main(self, input):
pass
@staticmethod
def static_1():
#repeated_code
pass
@staticmethod
def static_2():
#repeated_code
pass
As they share some #repeated_code
, I want to reduce the repetition in them by writing a function def repeat()
for the #repeated_code
.
Since they are inside static methods, I couldn't call a class method via self.repeat()
.
It doesn't seems reasonable to write the function outside the class, because the function repeat
is only used inside the class.
How should I achieve the propose of avoiding repeating myself?