[IronPython] What C# methods do __repr__ and __str__ use?

Douglas S. Blank dblank at brynmawr.edu
Sat May 24 18:10:43 CEST 2008

On Fri, May 23, 2008 3:37 pm, Toni Alatalo said:
> Douglas S. Blank kirjoitti:
>> will use it? Likewise, what C# method is used in Python's str(obj)?
> i don't know, but would guess ToString() .. and wonder about it if it
> wasn't that but something else :o
> repr() can't guess, i don't think there's an equivalent in .net, but can
> very well be mistaken there.

It looks like the C# method __str__ is used for the Python method, but in
IP2B2 the C# method __repr__ is getting overwritten by an auto generated
method. Is that a bug, or is there something I'm missing?

$ ipy2 -i python/graphics.py
>>> pm = Pixmap()
>>> pm.getPixel(0,0)                    # What is this calling?
<Pixel object at 0x2B>
>>> pm.getPixel(0,0).__repr__()         # This is repr() too
'<GraphicsCore+Pixel object at 0x2C [GraphicsCore+Pixel]>'
>>> pm.getPixel(0,0).__Repr__()         # This is mine
'<Pixel at (0,0)>'
>>> pm.getPixel(0,0).__str__()          # That is mine, and str()
'<Pixel at (0,0)>'
>>> pm.getPixel(0,0).ToString()         # Used by __repr__


>> -Doug
> ~Toni
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Douglas S. Blank
Associate Professor, Bryn Mawr College
Office: 610 526 6501

More information about the Ironpython-users mailing list