Any difference between dir() and locals() in Python?
<p>According to Python documentation, both <code>dir()</code> (without args) and <code>locals()</code> evaluates to the list of variables in something called <code>local scope</code>. First one returns list of names, second returns a dictionary of name-value pairs. Is it the only difference? Is this always valid?</p>

<pre><code>assert dir() == sorted( locals().keys() )
</code></pre>
