Message147711
With file xx.py:
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
Interactive mode:
$ python -V
Python 2.6.7
$ python -i xx.py
22
22
>>>
TypeError: int() argument must be a string or a number, not 'Foo'
>>> '%d' % y
'22'
>>> '%d' % y
TypeError: int() argument must be a string or a number, not 'Foo'
>>> '%d' % y
'22'
>>> '%d' % y
TypeError: int() argument must be a string or a number, not 'Foo'
It alternates between printing '22' and print a TypeError message. Expected it to be consistent.
Also, the first carraige-return (with no input) results in an error message. Did not expect an error message. In fact, typing pretty much anything (e.g. an undefined variable or raise(Exception())) results in the same error message.
On Mac OS X Darwin Kernel Version 10.8.0
Python 2.6.7 (r267:88850, Jul 6 2011, 13:57:37)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Thanks. |
|
Date |
User |
Action |
Args |
2011-11-15 22:04:50 | jayanth | set | recipients:
+ jayanth, ronaldoussoren |
2011-11-15 22:04:50 | jayanth | set | messageid: <1321394690.57.0.254973831289.issue13410@psf.upfronthosting.co.za> |
2011-11-15 22:04:49 | jayanth | link | issue13410 messages |
2011-11-15 22:04:49 | jayanth | create | |
|