Skip to main content

pytclsh: Pure Python TCL interpreter

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytclsh-0.0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytclsh-0.0.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file pytclsh-0.0.2.tar.gz.

File metadata

  • Download URL: pytclsh-0.0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytclsh-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6633c31f06a3b87cf8abaab8381069e9d01b2965dc2e99b6ba4e9ce7330ecc72
MD5 70938ac4f6a9d36ca9af951d3013e061
BLAKE2b-256 b7d3225ec52158972fa43202305d6556472c02580287f42eac853a25a22c8850

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytclsh-0.0.2.tar.gz:

Publisher: release.yml on netanelrevah/pytcl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytclsh-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pytclsh-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytclsh-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 350a4c4d15991a86126eab40494eb5d013acf1283da4fad9ec8887ac775175c2
MD5 d7557bd36e3392e092de9fe6f6f07704
BLAKE2b-256 9eaa542030d6423d51a7e39b9c76d16fd5fe3e7afff5ba3825730d87842b7506

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytclsh-0.0.2-py3-none-any.whl:

Publisher: release.yml on netanelrevah/pytcl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page