[Tutor] 3 simple, pithy and short questions (fwd)

Gonçalo Rodrigues op73418 at mail.telepac.pt
Fri Nov 21 19:49:04 EST 2003


On Fri, 21 Nov 2003 16:32:22 -0800 (PST), you wrote:

>
>> In recent years, the __str__()  method was added to numbers to make them
>> more uniform with the other Python types and classes.
>
>Hi everyone,
>
>
>Yikes, I'm totally wrong here!  Numbers still don't have __str__().  I
>should have double checked my assertions about this.  So we can call str()
>on numbers, but not __str__().  I misremembered the extent to which the
>numbers were unified with the other types.
>

They don't?

>>> int.__str__
<slot wrapper '__str__' of 'int' objects>
>>> (1).__str__
<method-wrapper object at 0x011C3A70>
>>> (1).__str__()
'1'

Tested in 2.3.

With my best regards,
G. Rodrigues



More information about the Tutor mailing list