Skip to content

Instantly share code, notes, and snippets.

@Karn
Last active July 29, 2017 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Karn/fe44acaa18078f916fb12d4009d6ab10 to your computer and use it in GitHub Desktop.
Save Karn/fe44acaa18078f916fb12d4009d6ab10 to your computer and use it in GitHub Desktop.
Python State Machine - Example Output
$ python
Python 2.7.13 (default, Apr 4 2017, 08:47:57)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from simple_device import SimpleDevice
>>> device = SimpleDevice()
Processing current state: LockedState
>>> device.on_event('device_locked')
>>> device.on_event('pin_entered')
Processing current state: UnlockedState
>>> device.state
UnlockedState
>>> device.on_event('device_locked')
Processing current state: LockedState
>>> device.state
LockedState
>>> device.on_event('device_locked')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment