[IronPython] __repr__ and __str__ for .NET types
Jonathan Jacobs
korpse-ironpython at kaydash.za.net
Wed May 24 16:59:57 CEST 2006
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
More information about the Ironpython-users
mailing list