Abend with cls.__repr__ = cls.__str__ on Windows.

eryksun () eryksun at gmail.com
Fri Mar 18 06:21:29 EDT 2011


On Thursday, March 17, 2011 8:24:36 PM UTC-4, J Peyret wrote:
>
> I suspect that object.__str__ is really object.__repr__ by default, as
> they both print out the same string, so that this doesn't make any
> sense.

They're not the same object, and they don't have all of the same methods. 

In [1]: object.__repr__ is object.__str__
Out[1]: False

In [2]: object.__repr__.__name__
Out[2]: '__repr__'

In [3]: object.__str__.__name__
Out[3]: '__str__'

In [4]: object.__repr__.__hash__()
Out[4]: 28910896

In [5]: object.__str__.__hash__()
Out[5]: 28910976

In [6]: object.__repr__.__call__(100)
Out[6]: '<int object at 0x01BE5234>'

In [7]: object.__str__.__call__(100)
Out[7]: '100'



More information about the Python-list mailing list