title: Python replace / with \
body: <p>I write some simple Python script and I want to replace all characters <code>/</code> with <code>\</code> in text variable. I have problem with character <code>\</code>, because it is escape character. When I use <code>replace()</code> method:</p>
  
  <pre><code>unix_path='/path/to/some/directory'
  unix_path.replace('/','\\')
  </code></pre>
  
  <p>then it returns following string: <code>\\path\\to\\some\\directory</code>. Of course, I can't use: <code>unix_path.replace('/','\')</code>, because <code>\</code> is escape character.</p>
  
  <p>When I use regular expression:</p>
  
  <pre><code>import re
  unix_path='/path/to/some/directory'
  re.sub('/', r'\\', unix_path)
  </code></pre>
  
  <p>then it has same results: <code>\\path\\to\\some\\directory</code>. I would like to get this result: <code>\path\to\some\directory</code>.</p>
  
  <p>Note: I aware of <code>os.path</code>, but I did not find any feasible method in this module.</p>