pyATS Tcl Integration

26.3 · active · verified Thu Apr 16

pyATS Tcl is a sub-component of the pyATS testing ecosystem, specializing in Tcl integration within Python. It provides an `Interpreter` class to extend the native Python-Tcl interaction, enabling two-way typecasting between Tcl and Python data structures and reusing existing Tcl libraries. pyATS is currently at version 26.3 and maintains an active development cycle with frequent releases for the broader pyATS framework.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a pyATS Tcl interpreter, execute Tcl commands, retrieve variable values, and perform basic typecasting between Tcl and Python data structures.

from pyats.tcl.interpreter import Interpreter

# Create a new Tcl interpreter instance
tcl_interpreter = Interpreter()

# Execute a simple Tcl command
result = tcl_interpreter.eval('set my_tcl_variable "Hello from pyATS Tcl!"')
print(f"Tcl command result: {result}")

# Retrieve the value of a Tcl variable
tcl_var_value = tcl_interpreter.eval('set my_tcl_variable')
print(f"Value of my_tcl_variable: {tcl_var_value}")

# Demonstrate basic typecasting (an enhancement over native tkinter.Tcl)
tcl_list_str = '{item1 item2 item3}'
py_list = tcl_interpreter.typecast(tcl_list_str, 'list')
print(f"Tcl list '{tcl_list_str}' typecasted to Python list: {py_list}")

view raw JSON →