class MyClass:
@staticmethod
def multiply(a, b):
return a * b
MyClass.multiply(2,3)
Будет работать, но staticmethod не принимает не cls, не self. def _add_unbounded_callback(cls, attr_name, func):
if func._is_event:
# if func is an event, the `attr_name` will be replaced by an event trigger,
# so we'll also give the ``func`` a new unique name to be used by the callback
# machinery.
cls.add_event(attr_name, func._transitions)
attr_name = f"_{attr_name}_{uuid4().hex}"
setattr(cls, attr_name, func)
Да, надо повышать квалификацию. class TestState(StateMachine):
wf_lexeme_and_meta = State(initial=True)
wf_tag = State()
wf_meaning_and_exp = State()
wf_sem_class = State()
# lexeme_and_meta_received = wf_lexeme_and_meta.to(wf_tag)
# tag_received = wf_tag.to(wf_meaning_and_exp)
# meaning_and_exp_received = wf_meaning_and_exp.to(wf_sem_class)
# sem_class_received = wf_sem_class.to(wf_lexeme_and_meta)
proceed = (wf_lexeme_and_meta.to(wf_tag) | wf_tag.to(wf_meaning_and_exp)
| wf_meaning_and_exp.to(wf_sem_class) | wf_sem_class.to(wf_lexeme_and_meta))
def __init__(self):
self.working_span = ""
self.working_memory = {
"lemma": "",
"meta": "",
"tag": "",
"meaning": "",
"exp": "",
"sem class": ""
}
super().__init__()
def before_proceed(self, event: str, source: State, target: State, message: str = ""):
print('I am working')
message = ". " + message if message else ""
return f"Running {event} from {source.id} to {target.id}{message}"
def on_enter_wf_tag(self):
print("Получено значение:" + self.working_span)
self.working_memory["lemma"] = self.working_span
self.working_memory["meta"] = input("Введите мета-информацию о слове")
def on_exit_wf_tag(self):
print("I am done!")
test_state = TestState()
print(test_state.current_state.name)
while True:
span = input()
test_state.proceed(span)
print(test_state.working_span)
print(test_state.working_memory)
print(test_state.current_state.name)
if span == "finish":
break