title: Substitute parenthesis for their regular expression
body: <p>I'm trying to copy a file,</p>
  
  <pre><code>&gt;&gt;&gt; originalFile = '/Users/alvinspivey/Documents/workspace/Image_PCA/spectra_text/HIS/jean paul test 1 - Copy (2)/bean-1-aa.txt'
  &gt;&gt;&gt; copyFile = os.system('cp '+originalFile+' '+NewTmpFile)
  </code></pre>
  
  <p>But must first replace the spaces and parenthesis before the open function will work:</p>
  
  <p>/Users/alvinspivey/Documents/workspace/Image_PCA/spectra_text/HIS/jean\ paul\ test\ 1\ -\ Copy\ \(2\)/bean-1-aa.txt</p>
  
  <p>spaces      ' '  --> '\ '
  parenthesis '('  --> '\('  etc.</p>
  
  <p>Replacing the spaces work:</p>
  
  <pre><code>&gt;&gt;&gt; originalFile = re.sub(r'\s',r'\ ', os.path.join(root,file))
  </code></pre>
  
  <p>but parenthesis return an error:</p>
  
  <pre><code>&gt;&gt;&gt; originalFile = re.sub(r'(',r'\(', originalFile)
  </code></pre>
  
  <p>Traceback (most recent call last):
    File "", line 1, in 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 151, in sub
      return _compile(pattern, flags).sub(repl, string, count)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 244, in _compile
      raise error, v # invalid expression
  sre_constants.error: unbalanced parenthesis</p>
  
  <p>Am I replacing parenthesis correctly?</p>
  
  <p>Also, when using re.escape() for this, the file is not returned correctly.  So it is not an alternative.</p>