tcl list to python list?

Paddy paddy3118 at netscape.net
Sun Sep 17 00:57:01 EDT 2006


jerry.levan at gmail.com wrote:
> Hi,
>
> I have a file that contains a "tcl" list stored as a string.  The list
> members are
> sql commands ex:
>  { begin { select * from foo
>                 where baz='whatever'}
>   {select * from gooble } end
>   { insert into bar values('Tom', 25) } }
>
> I would like to parse the tcl list into a python list...
>
> Any suggestions ( I am running Tkinter...)
>
> Jerry
Well, if you know TCL then read the bit about how to write a python
list:
 (http://docs.python.org/tut/node5.html#SECTION005140000000000000000)
Then write a TCL function to traverse your TCL list and write it out in
the python format.

Another suggestion might be to use CSV as an intermediary:
  http://tcllib.sourceforge.net/doc/csv.html
  http://docs.python.org/dev/lib/module-csv.html

Now if you know Python and not TCL ... :-)

- Paddy.




More information about the Python-list mailing list