I have a problem with passing windows path to a function in python. Now, if I hard code the path everything actually works. So, my code is:
from pymatbridge import Matlab
lab = Matlab(executable=r'"c:\Program Files \MATLAB\bin\matlab.exe"')
lab.start()
This works fine as I am using the raw string formatting to the hard-coded string. Now, the issue is that the string is passed as a variable. So, imagine I have a variable like:
path="c:\Program Files \MATLAB\bin\matlab.exe"
Now, I am unable to figure out how to get the equivalent raw string from this. I tried may things like shlex.quote(path)
and this makes issue with the \b
. Without conversion to the raw string, the space in Program Files
causes a problem, I think.