Python コード
Python は Pyodide(WebAssembly にコンパイルされた CPython)を通じて、 別のスレッドで実行されます。お使いのマシンに Python は不要です。
| シンボル | 役割 |
|---|---|
input | 入力ポートで受け取った値 |
vars | 実行変数の辞書 |
print(...) | 実行ログに書き込みます |
| 最後の式 | その値が result ポートに送られます |
commandes = input["commandes"]
payees = [c for c in commandes if c["statut"] == "payee"]total = sum(c["montant"] for c in payees)
print(f"{len(payees)} commandes payées, total {total} €")
{"nombre": len(payees), "total": total}標準ライブラリ
Section titled “標準ライブラリ”CPython の標準ライブラリが使えます。json、re、datetime、hashlib、
base64、itertools、collections など。
import hashlib, hmac
signature = hmac.new( vars["secret"].encode(), input["corps"].encode(), hashlib.sha256,).hexdigest()
{"signature": signature}外部パッケージ
Section titled “外部パッケージ”ボックスの packages フィールドに宣言してください。初回実行時に PyPI から
ダウンロードされてキャッシュされ、以降はオフラインで読み込まれます。
停止とタイムアウト
Section titled “停止とタイムアウト”timeout の超過や実行の停止は、KeyboardInterrupt によって処理を中断し、
必要であればスレッドを終了させます。