Skip to main content

XState for Python

XState for Python - work in progress!

How to use

from xstate.machine import Machine

lights = Machine(
    {
        "id": "lights",
        "initial": "green",
        "states": {
            "green": {"on": {"TIMER": "yellow"},},
            "yellow": {"on": {"TIMER": "red"}},
            "red": {"on": {"TIMER": "green"}},
        },
    }
)

state = lights.initial_state # state.value is green

state = lights.transition(state, "TIMER") # state.value is yellow
state = lights.transition(state, "TIMER") # state.value is red
state = lights.transition(state, "TIMER") # state.value is green again

More advanced examples in the "examples" folder

Testing

  1. Run python3.7 -m venv .venv to create a virtual environment
  2. Run source .venv/bin/activate to go into that virtual environment
  3. Run pip install -r requirements_dev.txt to install all of the dependencies in requirements.txt (which includes pytest)
  4. Run npm i @scion-scxml/test-framework to download scxml files
  5. Run pytest to run the tests! 👩‍🔬

SCXML

SCXML tests are ran from the SCION Test Framework module.

Related Projects

Release files for xstate 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xstate 0.0.1
File Size Uploaded
xstate-0.0.1.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xstate 0.0.1
File Interpreter ABI Platform
xstate-0.0.1-py2-none-any.whl Python 2 none any Details

Total release size: 21.5 kB

Release files / xstate-0.0.1.tar.gz

Download URL xstate-0.0.1.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e17a78934a8c9ea0c823891d0194f58a59cfd273f8ced0293f45c89f214a8494
BLAKE2b-256 checksum
How to use checksums
830c36a48f52f7344677fd176f65a5599e39eec0ea50163c5376327ff889bf32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

Release files / xstate-0.0.1-py2-none-any.whl

Download URL xstate-0.0.1-py2-none-any.whl
Size 12.4 kB
Tags Python 2
SHA-256 checksum
How to use checksums
568f3d38634f03966a0121c0c98ed79d38ffd2e10b4f9c7be91e3cd369fcc500
BLAKE2b-256 checksum
How to use checksums
cd7ff2b32f2aec21c1f317ca53ffe657ff2ddb33ab3f02fd02ebb5087e3815ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page