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.1.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.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytclsh-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 6067b25449d04fd372c699ac04d6a0a7cdd6be828d6524700d336a2ebbb1f5ff
MD5 73b5b762c7cb5a5f512384fe0090d468
BLAKE2b-256 cdbb2ed5654bec89a43e0e4c892b22f087c23bf853595a897ba6669c32b0803e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytclsh-0.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pytclsh-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e056d29581358d8cd148b770304393f7b445a678228ecb0d8e6687c28233c6e
MD5 d8a4ec2389fb307f154bfb97a189079d
BLAKE2b-256 6532131078a799b592f29ffb74c7654a07a5ded0b22619c32392c5c02702e90a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytclsh-0.0.1-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