str() for containers

Dan Bishop danb_83 at
Sat Jun 19 04:36:24 CEST 2004

Donn Cave <donn at> wrote in message news:<donn-19AA94.08563918062004 at>...
> In article <ad052e5c.0406172153.128f765f at>,
>  danb_83 at (Dan Bishop) wrote:
> > All Java classes include a toString() method (defined in the root
> > class java.lang.Object), which returns the string representation of
> > that object...[big snip]
> > The difference from Python's approach is that there isn't an
> > equivalent to Python's str/repr distinction.  Obviously, when there's
> > only one string conversion method, you won't use the wrong one.
> It would be fun to apply that reasoning to arithmetic
> operators.  Which one does Java support?

toString() usually behaves more like Python's str than repr.  An
exception is Double.toString, which returns 16 signifcant digits.

Jython uses toString() to implement both __str__ and __repr__ for Java

More information about the Python-list mailing list