Windows path with spaces in python
<p>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:</p>

<pre><code>from pymatbridge import Matlab
lab = Matlab(executable=r'"c:\Program Files \MATLAB\bin\matlab.exe"')
lab.start()
</code></pre>

<p>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:</p>

<pre><code>path="c:\Program Files \MATLAB\bin\matlab.exe"
</code></pre>

<p>Now, I am unable to figure out how to get the equivalent raw string from this. I tried may things like <code>shlex.quote(path)</code> and this makes issue with the <code>\b</code>. Without conversion to the raw string, the space in <code>Program Files</code> causes a problem, I think. </p>