title: How to get rid of extensions from file basename using python
body: <p>I have got the complete path of files in a list like this:</p>
  
  <pre><code>a = ['home/robert/Documents/Workspace/datafile.xlsx', 'home/robert/Documents/Workspace/datafile2.xls', 'home/robert/Documents/Workspace/datafile3.xlsx']
  </code></pre>
  
  <p>what I want is to get just the file NAMES without their extensions, like:</p>
  
  <pre><code>b = ['datafile', 'datafile2', 'datafile3']
  </code></pre>
  
  <p>What I have tried is:</p>
  
  <pre><code>xfn = re.compile(r'(\.xls)+')
  for name in a:
      fp, fb = os.path.split(fp)
      ofn = xfn.sub('', name)
      b.append(ofn)
  </code></pre>
  
  <p>But it results in:</p>
  
  <pre><code>b = ['datafilex', 'datafile2', 'datafile3x']
  </code></pre>