title: Split by comma and strip whitespace in Python
body: <p>I have some python code that splits on comma, but doesn't strip the whitespace:</p>
  
  <pre><code>&gt;&gt;&gt; string = "blah, lots  ,  of ,  spaces, here "
  &gt;&gt;&gt; mylist = string.split(',')
  &gt;&gt;&gt; print mylist
  ['blah', ' lots  ', '  of ', '  spaces', ' here ']
  </code></pre>
  
  <p>I would rather end up with whitespace removed like this:</p>
  
  <pre><code>['blah', 'lots', 'of', 'spaces', 'here']
  </code></pre>
  
  <p>I am aware that I could loop through the list and strip() each item but, as this is Python, I'm guessing there's a quicker, easier and more elegant way of doing it.</p>