title: Is there a need for a "use strict" Python compiler?
body: <p>There exist <a href="https://stackoverflow.com/questions/35470/are-there-any-static-analysis-tools-for-python">static analysis tools for Python</a>, but compile time checks tend to be diametrically opposed to the <a href="http://python-history.blogspot.com/2009/01/introduction-and-overview.html" rel="nofollow noreferrer">run-time binding philosophy</a> that Python embraces. It's <em>possible</em> to wrap the standard Python interpreter with a static analysis tool to enforce some "<a href="http://perldoc.perl.org/strict.html" rel="nofollow noreferrer">use strict</a>"-like constraints, but we don't see any widespread adoption of such a thing.</p>
  
  <p>Is there something about Python that makes "use strict" behavior unnecessary or especially undesirable?</p>
  
  <p>Alternatively, is the "use strict" behavior unnecessary in Perl, despite its widespread adoption?</p>
  
  <p>Note: By "necessary" I mean "practically necessary", not strictly necessary. Obviously you <em>can</em> write Perl without "use strict," but (from what I've seen) most Perl programmers <em>do</em> use it.</p>
  
  <p>Note: The Python interpreter-wrapper need not <em>require</em> "use strict"-like constraints -- you could use a pseudo-pragma similar to "use strict" that would be ignored by the normal interpreter. I'm not talking about adding a language-level feature.</p>
  
  <hr />
  
  <p>Update: Explaining what "use strict" does in Perl per comments. (Link to official docs is in the first paragraph.)</p>
  
  <p>The "use strict" directive has three distinct components, only two of which are really interesting:</p>
  
  <ul>
  <li><p>use strict vars: Statically checks lexically scoped variable usage in your program. (Keep in mind that, in Python, there is basically only <code>global</code> scope and <code>local</code> scope). Many Python linters check for this sort of thing. Since it's the only static analysis that they can do, the linters assume you use straightforward lexical scoping and warn you about things that appear wrong in that sense until you tell them to shut up; i.e.</p>
  
  <pre><code>FOO = 12
  foo += 3
  </code></pre>
  
  <p>If you're not doing anything fancy with your namespaces this can be useful to check for typos.</p></li>
  <li><p>use strict refs: Prevents symbolic namespace dereferencing. Python's closest analog is using <code>locals()</code> and <code>globals()</code> to do symbolic binding and identifier lookup.</p></li>
  <li><p>use strict subs: No real analog in Python.</p></li>
  </ul>