[IronPython] What C# methods do __repr__ and __str__ use?
Douglas S. Blank
dblank at brynmawr.edu
Wed May 28 21:22:12 CEST 2008
Anyone have an answer for this: I can't write C# code that has its own
method for use in repr(). Am I missing something?
-Doug
Douglas S. Blank wrote:
> 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__
> 'GraphicsCore+Pixel'
>
> -Doug
>
>>> -Doug
>>>
>> ~Toni
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>
>
More information about the Ironpython-users
mailing list