Python – Know any creative ways to interface Python with Tcl


Here's the situation. The company I work for has quite a bit of existing Tcl code, but some of them want to start using python. It would nice to be able to reuse some of the existing Tcl code, because that's money already spent. Besides, some of the test equipment only has Tcl API's.

So, one of the ways I thought of was using the subprocess module to call into some Tcl scripts.

  • Is subprocess my best bet?
  • Has anyone used this fairly new piece of code: Plumage? If so what is your experience (not just for Tk)?
  • Any other possible ways that I have not considered?

Best Solution

I hope you're ready for this. Standard Python

import Tkinter
tclsh = Tkinter.Tcl()
    proc unknown args {puts "Hello World!"}
    }"!dlroW olleH" stup{ sgra nwonknu corp

Edit in Re to comment: Python's tcl interpreter is not aware of other installed tcl components. You can deal with that by adding extensions in the usual way to the tcl python actually uses. Here's a link with some detail