Look up a tuple in a python dictionary matching (x,y) or (y,x)
<p>I've a dictionary with a <code>(x,y)</code> key, where <code>(x,y)</code> means the same as <code>(y,x)</code>, How should I do this ?</p>

<p>I can do:</p>

<pre><code>&gt;&gt;&gt; d = {(1,2): "foo"}
&gt;&gt;&gt; i = d.get(2,1)
&gt;&gt;&gt; if i is None:
...     i = d.get((1,2))
...
&gt;&gt;&gt; i
'foo'
</code></pre>

<p>Is there a better way of doing this, so <code>d.get((2,1))</code> would match the key <code>(1,2)</code> directly ?
ideally i'd want to insert e.g. <code>(2,1)</code> and not have it be distinct from the <code>(1,2)</code> key as well.</p>
