Alternate error and no-error in python interactive mode
<p>With file xx.py:</p>

<pre><code>class Foo(object):
    def __init__(self, x):
        self.x = x

    def __long__(self):
        return long(self.x)

    def __float__(self):
        return float(self.x)


y = Foo(22)

print '%d' % y
print '%d' % y
</code></pre>

<p>Interactive mode:</p>

<pre><code>$ python -V
Python 2.6.7

$ python -i xx.py 
22
22
&gt;&gt;&gt; 
TypeError: int() argument must be a string or a number, not 'Foo'
&gt;&gt;&gt; '%d' % y
'22'
&gt;&gt;&gt; '%d' % y
TypeError: int() argument must be a string or a number, not 'Foo'
&gt;&gt;&gt; '%d' % y
'22'
&gt;&gt;&gt; '%d' % y
TypeError: int() argument must be a string or a number, not 'Foo'
</code></pre>

<p>Why does it alternate between printing '22' and raising a TypeError?</p>

<p>Why does it raise an error on the first carriage return (with no input)?</p>

<p>Thanks.</p>
