Problem sending variables to Client.RunPythonEx
Forums
I had someone come to me with a problem in which they were using the Client.RunPythonEx to send variables to their python script. Every time they ran their script the had the following error: "Python generated the following error: EOL while scanning string literal". What they were trying to do was to send the working directory to python using the RunPythonEx. So there code was something like this:
Dim myPythonVariables(3) As Variant
Sub Main
Dim sStringVariable
Dim iNumericVariable
sStringVariable = Client.WorkingDirectory()
iNumericVariable = 3
myPythonVariables(0) = "Random Text"
myPythonVariables(1) = 3747892
myPythonVariables(2) =sStringVariable
myPythonVariables(3) = iNumericVariable
Client.RunPythonEx "Macros.ILB\Example 1.py", myPythonVariables
End Sub
The sStringVariable would through an error. The problem is that a variable contain a path has "\" in it which are escape character in Python. What was needed was to add a line that escaped the "\" so that it could become "\\" instead. The following line was added to the script after the sStringVariable = Client.WorkingDirectory()
and that fixed the problem.
sStringVariable = iReplace(sStringVariable, "\", "\\")
I work with modul sys, but I…
I work with modul sys, but I can use the parameters only once a time?