Python for TCLer

Cameron Laird claird at lairds.com
Wed Jun 23 14:18:21 EDT 2004


In article <849e4506.0406230949.605df12e at posting.google.com>,
Bhushit Joshipura <bhushit at hotmail.com> wrote:
>I am almost brainwashed to forsake TCL for Python. However, I wanted
>to ask a few preliminary questions before I jump in.
>
>The over all picture of my project would look like:
>
>Front End : TCL scripts - Our API to users (Can't change because of
>legacy)
>----->Middle Layer : Framework (PYTHONization Target)
>Back End: TCL API from vendors (Can't change), in-house Expect API
>(can't risk for reliability)
>
>1. One of my vendors supplies TCL package only. Can I call TCL
>procedures from Python back end? What about Expect scripts?
>
>2. OTOH, all my scripts are in TCL. Can I invoke python from TCL and
>retain states in python?
>
>3. This is closely related to uplevel question already discussed in
>this group. We have one control structure in our API that has done
>wonders in productivity. I can not let it go.
>
>Does python let me write a control structure? It looks like:
>
>set x 10
>set y 5
>controlStructure {
> do something with $x until y becomes 3 ;#This is evaluated in
>caller's frame
>}
>
>4. Does there exist a mapping of TCL facilities over Python? It will
>help me in training man power. Ideal place would describe
>
>uplevel "..."
>would translate to
><python equivalent>
>
>eval "..."
>would translate to
><python equivalent>
>
>subst "..."
>...
>
>5. Does Aspect Oriented Extension exist for Python? I know TOS
>(http://www.aopsys.com/tos) is no longer maintained for TCL.
			.
			.
			.
Yes.  The answer to most things is, "Yes".  Yes, Python
can get at your existing Tcl stuff; in fact, a full
Python installation *includes* Tcl, and Python can exe-
cute Tcl source in-process! <URL:
http://groups.google.com/groups?selm=545D8B2DF16A6E76.6993863E4741C004.1E9B970F7929B34E%40lp.airnews.net >

However, Python does NOT encourage new control structures
the way some denominations of Tcl does, and I discourage
"phrasebooks" for just the reason [uplevel] illustrates:
simple-minded transliteration of a Tcl [uplevel] into 
Python is certain to produce code that's not just non-
idiomatic, but unmaintainable and ugly.

On the other hand, you'll find a lot to learn and like in
Python's control structures, and, if you start building
the phrasebook by starting with [eval], [exec], [glob],
..., I'm sure you'll receive plenty of help filling out
the entries.
-- 

Cameron Laird <claird at phaseit.net>
Business:  http://www.Phaseit.net



More information about the Python-list mailing list