I wanted to write a class function which takes Signal object as a parameter and returns its copy. Then I wanted to overload this function with an instance function that returns copy of self argument. I have a following code:
@classmethod
def copy(cls, arg):
if not isinstance(arg, Signal):
raise ValueError("Argument must be of type Signal")
result = Signal()
result.framerate = arg.framerate
return result
def copy(self):
return FragmentsSignal.copy(self)
and
Signal1 = Signal(100)
Signal2 = signal1.copy()
But after calling the function copy my code goes into infinite recursive loop and throws name of this site as an exception. My questions are:
Do I properly use python function overloading mechanism?
How can I pass *this argument to a class function within my class?