[Python-3000] Recursive str
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Apr 16 05:44:53 CEST 2008
Paul Moore wrote:
> If you don't
> want to change your code, write
>
> from my_repr import my_repr as repr
But repr() itself doesn't do anything -- it just
invokes the __repr__ method of its argument. So
you can't actually accomplish anything by replacing
it, unless your replacement does a lot of un-duckish
type testing.
What you actually need to replace is the __repr__
method of the builtin string object, and I'm not
sure if you can do that from Python.
--
Greg
More information about the Python-3000
mailing list