python operator overloading for mismatched types does not work if the first type is a ctypes type
<p>Here is the code:</p>

<pre><code>&gt;&gt;&gt; from ctypes import *
&gt;&gt;&gt; class T:
...     def __and__(self, other):
...             return 1
...
&gt;&gt;&gt; T() &amp; T()
1
&gt;&gt;&gt; T() &amp; "1"
1
&gt;&gt;&gt; T() &amp; 1
1
&gt;&gt;&gt; T() &amp; c_ulong(3)
1
&gt;&gt;&gt; c_ulong.__and__ = lambda self, other: 1
&gt;&gt;&gt; c_ulong(3) &amp; c_ulong(2)
1
</code></pre>

<p>All good so far. But why doesn't the code below work in Python 2.7.2?</p>

<pre><code>&gt;&gt;&gt; c_ulong(3) &amp; T()
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: unsupported operand type(s) for &amp;: 'c_ulong' and 'instance'
&gt;&gt;&gt; c_ulong(3) &amp; 2
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: unsupported operand type(s) for &amp;: 'c_ulong' and 'int'
</code></pre>

<p>For a class that I define, there seems to be no problem to support any type of second operand, but when I am attaching the function to a ctypes type, the function is called when the second operand is of the same type, but not if the operand is of a different type.
I really want to allow bitwise and and or between ctypes integers and regular integers where the result is a ctypes integer.</p>