Python
Goal
Write the standard Python block, which most later lessons use. Time: 5 minutes. Needs: Python 3.
Things to know
- The runner looks for
python3, thenpython, and runs it unbuffered (-u). Print statements appear in order. - An uncaught exception exits with a non-zero code, so the block fails and the traceback appears in the error output.
ensure_ascii=Falsekeeps Unicode readable. The output is valid JSON either way.- Use
print(..., file=sys.stderr)for diagnostics. - Only the standard library is guaranteed. If you
pip installsomething, it’s installed for that interpreter on this computer, not for the workflow.
Check your run
Execute step with {"trigger":{"text":"Grüße 👋"}} publishes message: "Grüße 👋".
Exercise
Publish slug: the text in lower case, with runs of non-alphanumeric characters replaced by -, and leading and trailing - removed.