Ive been running quite a few python scripts using EXEC, so I thought it might be nice to have a function to execute these scripts.
function saved as python:
$ReturnVar = print(exec('[$$PythonExePath]','[$$PythonLibPath]\\[$PythonFunction].py [$PythonArgument]',8));
return(substr($ReturnVar,10,990));
substitution vars:
$$PythonExePath
$$PythonLibPath
input Vars:
$PythonFunction
$PythonArgument
local var:
$ReturnVar
python script: (saved as test.py)
from sys import argv
lstArgs = argv[1:]
print '||'.join(lstArgs)
to execute the python script: (GlobalVar = $TestVar)
$TestVar = python(‘test’,’“go cubs” “another argument”’);
The python script is pretty simple, but takes an argument, and the print returns a string value. What happens in the script is pretty open ended.
Im not sure what this would do on a per-record basis in a dataflow, but used in a script this should be pretty harmless.
[edit] if you run this per record, you’re going to spam STDOUT with the print return values per function call. So that could be a bad idea. You can remove the print from the function… but running per-record, it still runs very very slow.
jlynn73 (BOB member since 2009-10-27)