En Thu, 21 Jun 2007 00:24:28 -0300, Kenji Noguchi <[EMAIL PROTECTED]>  
escribió:

> Example2 -- pass an instance of a class with __int__()
>>>> class X:
> ...     def __init__(self, v):
> ...         self.v = v
> ...     def __int__(self):
> ...         return self.v
> ...
>>>> y = X(0x80000000)
>>>> "%08x" % y
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: int argument required
>>>>
>
> The behavior looks inconsistent.  By the way __int__ actually
> returned a long type value in the Example2.  The "%08x" allows
> either int or long in the Example1, however it accepts int only
> in the Example2.   Is this a bug or expected?

It is a bug, at least for me, and I have half of a patch addressing it. As  
a workaround, convert explicitely to long before formatting.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to