Skip to content

How to get the callback result? #608

Answered by aleneum
vba34520 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @vba34520,

callback return values are ignored (unless they are conditions, in this case they must return a 'truesy' or 'falsy' value).
You cannot directly return values from callbacks.
You can either assign variables to your stateful object (the model; in your case also the machine; e.g. self.temp_map) or pass a referenced object as a parameter:

from transitions import Machine


class TempMachine(Machine):
    def __init__(self):
        self.temp = 0
        states = ['centigrade', 'fahrenheit', 'kelvin']
        Machine.__init__(self, states=states, send_event=True, initial=states[0],
                         ignore_invalid_triggers=True, auto_transitions=False)
        self.add_t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vba34520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants