Closed salmanisd closed 4 years ago
Missing "State" in from transitions import Machine
Hi @salmanisd,
thank you for taking the time to open an issue and also creating a PR. However, I cannot reproduce your issue. Combining Matter
and the construction of Machine
results in something like this:
from transitions import Machine
class Matter(object):
pass
lump = Matter()
machine = Machine(model=lump, states=['solid', 'liquid', 'gas', 'plasma'], initial='solid')
# Lump now has state!
lump.state
where State
shouldn't be needed.
In the passage about the State
class (after "The following snippets illustrate several ways to achieve the same goal: ") we need to import it though. I added a line in the code example here which hopefully clarifies the need for an import there.
Hi aleneum,
My issue was that I was trying the different example code blocks in the same file going step by step so while the above block you mentioned didnt give me an error, the next blocks involving "State" will give an error. So I thought for noobs like me it would be better if all the required modules for just imported at once in the start. You can close this issue and the PR.
@salmanisd,
So I thought for noobs like me it would be better if all the required modules for just imported at once in the start. You can close this issue and the PR.
I see. yeah, that's probably a matter of taste. nevertheless it's definitely worth to report and also to clarify this. I have to rely on people like you to find these issues because I hardly read the documentation myself. So thanks again for your time and effort!