title: How can I strip the file extension from a list full of filenames?
body: <p>I am using the following to get a list with all the files inside a directory called <code>tokens</code>:</p>
  
  <pre><code>import os    
  accounts = next(os.walk("tokens/"))[2]
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>&gt;&gt;&gt; print accounts
  ['.DS_Store', 'AmieZiel.py', 'BrookeGianunzio.py', 'FayPinkert.py', 'JoieTrevett.py', 'KaroleColinger.py', 'KatheleenCaban.py', 'LashondaRodger.py', 'LelaSchoenrock.py', 'LizetteWashko.py',  'NickoleHarteau.py']
  </code></pre>
  
  <p>I want to remove the extension <code>.py</code> from each item in this list. I managed to do it individually using <code>os.path.splitext</code>:</p>
  
  <pre><code>&gt;&gt;&gt; strip = os.path.splitext(accounts[1])
  &gt;&gt;&gt; print strip
  ('AmieZiel', '.py')
  &gt;&gt;&gt; print strip[0]
  AmieZiel
  </code></pre>
  
  <p>I'm sure I'm overdoing things, but I can't figure out a way to strip the file extension from all the items in the list with a for-loop.</p>
  
  <p>What would be the proper way to do it?</p>