Remember which decorators:
@decorate
def foo(...):
...
exactly equivalent to:
def foo(...):
...
foo = decorate(foo)
, self . , , , , , . started AttributeError, _started , None, None, , , .
, :
import functools
def started(func):
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
if not self._started:
raise ...
else:
return func(self, *args, **kwargs)
return wrapper
; , , - "" , . functools.wraps - , - ; wrapper docstring , "" .
, .