- May
- 382
- 2
What techniques are available to return values from %@python[] to TCC ?
I have been exploring some straightforward ways, but I can't see how to get something out of @python except for console output. Note that I am not using the supported ActivePython but another distribution, so my issue could be all there. Anyways, this is what I tried:
I have been exploring some straightforward ways, but I can't see how to get something out of @python except for console output. Note that I am not using the supported ActivePython but another distribution, so my issue could be all there. Anyways, this is what I tried:
- Capture standard output: set x=%@python[print 1+1] >out
This sets x=0 (python's exit code?), creates an empty out file and prints 2 to the console. - Set a TCC variable from python: how can I do that?
Incidentally I discovered that the persistent python interpreter gets its own frozen environment block, so setting environment variables, like $PATH, from python is pointless because changes aren't reflected in TCC's environment block. - Write to a file from python. Here is a working example, but I would like to find a memory based solution as well, like #2.
Code:
set tmpf=%@unique["%[TEMP]"]
echo>nul %@python[with open(r'%[tmpf]','w') as tmpf: print >>tmpf, 1+1]
type "%[tmpf]"
del "%[tmpf]"