Inspiration
I have a homework assignment where I have to implement an NFA, and generally always end up making state machines when doing system design, so its something I find genuinely useful
What it does
It's a python package that abstracts away state machine logic. All you have to do is identify the states in your system, write your action functions, and create a state transition matrix. Then call start and trigger events as needed. It does the rest.
How we built it
Using uv python package manager and my real human brain
Challenges we ran into
The kind of abstraction implemented in Python States gets a little tricky with passing around *args and **kwargs. Also, having the state machine emulation running in an asyncio coroutine leads to some headaches with race conditions and the likes.
Accomplishments that we're proud of
It seems to work pretty well, which I wasn't really expecting. I was going for more of a duct-taped together pile of python mess. Considering I did 0 planning and wasn't decided on the project until the day of the hackathon, I'm happy with my on the fly engineering.
What we learned
Lots of weird gimmicky python nonsense that really doesn't get touched most of the time. TypeAliases, Callable arguments, arg passing, and more are just not very pythony and were fun to mess with. Also I felt that I got better at async program design.
What's next for Python-States
Concurrent execution. The first thing I stated as my inspiration isn't implemented. Python-States works for finite state machines but does not support ambiguity/nondeterminism.
Built With
- asyncio
- pypi
- python
- uv
Log in or sign up for Devpost to join the conversation.