nrevah-pytcl: Pure Python TCL interpreter
Project description
pytcl
Pure Python TCL interpreter and parser library.
Installation
pip install pytcl
Usage
Interpreter
from pytcl.interpreter import Interpreter
i = Interpreter()
i.substitute_string("set x 42") # "42"
i.substitute_string("expr {$x * 2}") # "84"
i.substitute_string("set x") # "84"
Evaluate a .tcl file:
from pathlib import Path
from pytcl.interpreter import Interpreter
i = Interpreter()
i.substitute_file(Path("script.tcl"))
Custom commands
Commands are plain callables stored in the namespace:
from pytcl.interpreter import Interpreter
i = Interpreter()
i.namespace["double"] = lambda args, ns: str(int(args[0]) * 2)
i.substitute_string("double 21") # "42"
Parser
Parse Tcl source into a typed tree without executing it:
from pytcl.words import TCLScript
script = TCLScript.read(iter("set x [expr {1 + 2}]"))
for command in script.commands:
print(command.name, command.args)
Built-in commands
set, unset, expr, if / elseif / else, while, foreach, proc, return, break, continue, incr, append, puts, error
Development
uv sync --all-extras # install dependencies
uv run pytest # unit tests
uv run pytest integrations/ # integration tests (requires Docker)
uv run ruff check . # lint
uv run pre-commit run --all-files
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nrevah_pytcl-0.0.4.tar.gz.
File metadata
- Download URL: nrevah_pytcl-0.0.4.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ef7d9954e33c623d45098691f4f756f75f0b278a4c32dfa26a53076964008a2
|
|
| MD5 |
809826fb37edbe0356a7470332f40f86
|
|
| BLAKE2b-256 |
7603b0ef791071499281e0fb2296d31591b1171925d630d4d1ed214106c9f9c4
|
Provenance
The following attestation bundles were made for nrevah_pytcl-0.0.4.tar.gz:
Publisher:
release.yml on netanelrevah/pytcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nrevah_pytcl-0.0.4.tar.gz -
Subject digest:
4ef7d9954e33c623d45098691f4f756f75f0b278a4c32dfa26a53076964008a2 - Sigstore transparency entry: 1280186859
- Sigstore integration time:
-
Permalink:
netanelrevah/pytcl@8b55acd59bab8b170ad021a9043a80e4af3c6aa7 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/netanelrevah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8b55acd59bab8b170ad021a9043a80e4af3c6aa7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nrevah_pytcl-0.0.4-py3-none-any.whl.
File metadata
- Download URL: nrevah_pytcl-0.0.4-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24a336aec2a67f40978f2fd32064cb9008cd537b17ad837d2a0ee3a16f8f426
|
|
| MD5 |
3f09178649b51851cdb584e1e9c2ad0a
|
|
| BLAKE2b-256 |
ae3ae88869a5d5d95e7bdceed2cdce5e9dc8cba5cedb31cd50e81bb364a95f8a
|
Provenance
The following attestation bundles were made for nrevah_pytcl-0.0.4-py3-none-any.whl:
Publisher:
release.yml on netanelrevah/pytcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nrevah_pytcl-0.0.4-py3-none-any.whl -
Subject digest:
e24a336aec2a67f40978f2fd32064cb9008cd537b17ad837d2a0ee3a16f8f426 - Sigstore transparency entry: 1280186860
- Sigstore integration time:
-
Permalink:
netanelrevah/pytcl@8b55acd59bab8b170ad021a9043a80e4af3c6aa7 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/netanelrevah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8b55acd59bab8b170ad021a9043a80e4af3c6aa7 -
Trigger Event:
push
-
Statement type: