<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Passing Curiosity: Posts tagged corner cases</title>
    <link href="https://passingcuriosity.com/tags/corner-cases/corner-cases.xml" rel="self" />
    <link href="https://passingcuriosity.com" />
    <id>https://passingcuriosity.com/tags/corner-cases/corner-cases.xml</id>
    <author>
        <name>Thomas Sutton</name>
        
        <email>me@thomas-sutton.id.au</email>
        
    </author>
    <updated>2012-08-18T00:00:00Z</updated>
    <entry>
    <title>PyconAU 2012: Python's dark corners</title>
    <link href="https://passingcuriosity.com/2012/dark-corners/" />
    <id>https://passingcuriosity.com/2012/dark-corners/</id>
    <published>2012-08-18T00:00:00Z</published>
    <updated>2012-08-18T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Peter Lovett is a programmer and trainer.</p>
<p>Python’s dark corners. Covering 2.x with a few tips on 3; things to avoid,
etc. Python is a fantastic language but it’s not perfect and there are a few
dark corners which need to be worked around.</p>
<p>Python is a deceptively simple language: the surface simplicity hides a deal
of complexity.</p>
<p>Reference to the algorithmic trading incident.</p>
<h3 id="oo">OO</h3>
<p>Python really is object oriented. This has a few more implications: “modules”
and functions are first-class.</p>
<h3 id="references">References</h3>
<p>Python uses references by default. Use <code>is</code> for reference equality, not <code>==</code>.
Some types (int, tuple, etc) are immutable.</p>
<p>Rebinding is sometimes an accident. When of a built-in, it’s often
catastrophic. Use <code>__builtin__</code> to get these things back.</p>
<p>Pass by reference is the default (and only option). The only pass by value is
to copy it. Lots of options for lists (slice <code>[:]</code>), the <code>copy</code> module.</p>
<h3 id="operators">Operators</h3>
<p>No <code>++</code> or <code>--</code> operators. “Mutating” operators are designed so as not to be
mutating: <code>+=</code>, etc. rather than <code>++</code>.</p>
<h3 id="typing">Typing</h3>
<p>If you’re checking types, you’re doing it wrong. “Duck typing”. #sigh</p>
<h3 id="numerics">Numerics</h3>
<p>Floating point arithmetic is floating point arithmetic.</p>
<h3 id="tuples">Tuples</h3>
<p>Immutable, but only the tuple itself (i.e. the references it contains, not
their referents).</p>
<h3 id="arguments">Arguments</h3>
<ul>
<li><p>Support both ordinal and keyword parameters.</p></li>
<li><p>Default values. Default values are created at load time, so should probably
be immutable.</p></li>
</ul>
<h3 id="namespaces">Namespaces</h3>
<p>Scoping: scoping of variables is based on use within the scope, not dynamic.</p>
<p>Visibility of globals. Better to just avoid variables in global scope.</p>]]></summary>
</entry>

</feed>
