[IronPython] __repr__ and __str__ for .NET types

Dino Viehland dinov at exchange.microsoft.com
Wed May 24 17:30:49 CEST 2006


I've opened a bug for us to reconsider what we're doing here.  I'm not sure what the final solution will be but we'll make sure to follow up on the mailing list with what we end up with.  Thanks for suggestion (and the interesting discussion!)

Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs
Sent: Wednesday, May 24, 2006 8:00 AM
To: Discussion of IronPython
Subject: Re: [IronPython] __repr__ and __str__ for .NET types

Neville Bagnall wrote:
> FWIW in the general case I would have something equivalent to:
>
> def GenRepr(object):
>      strrep=object.ToString()
>      if len(strrep)<40 and strrep.find('\n')==-1:
>          return "<%s: %s>" % (object.__class__.__name__, repr(strrep)[1:-1])
>      else:
>          return "<%s at 0x%x>" % (object.__class__.__name__, id(object))
>
> i.e. include a string representation only where it is reasonably concise,
> and include the markers in both cases.

I would be happy with something like that and I think it ends up being a
better solution than what is currently the situation.
--
Jonathan

_______________________________________________
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