Split by comma and strip whitespace in Python
<p>I have a simple piece of code:</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 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>
