Co powoduje „niezwiązana metoda __init __ () musi być wywołana jako instancja jako pierwszy argument” z tego kodu Pythona?
Mam tę klasę:
from threading import Thread
import time
class Timer(Thread):
def __init__(self, interval, function, *args, **kwargs):
Thread.__init__()
self.interval = interval
self.function = function
self.args = args
self.kwargs = kwargs
self.start()
def run(self):
time.sleep(self.interval)
return self.function(*self.args, **self.kwargs)
i nazywam to tym skryptem:
import timer
def hello():
print \"hello, world
t = timer.Timer(1.0, hello)
t.run()
i otrzymaj ten błąd i nie mogę zrozumieć dlaczego:unbound method __init__() must be called with instance as first argument