What is the pythonic way to count the leading spaces in a string?
<p>I know I can count the leading spaces in a string with this:</p>

<pre><code>&gt;&gt;&gt; a = "   foo bar baz qua   \n"
&gt;&gt;&gt; print "Leading spaces", len(a) - len(a.lstrip())
Leading spaces 3
&gt;&gt;&gt;
</code></pre>

<p>But is there a more pythonic way?</p>
