str() for containers
Dan Bishop
danb_83 at yahoo.com
Fri Jun 18 22:36:24 EDT 2004
Donn Cave <donn at u.washington.edu> wrote in message news:<donn-19AA94.08563918062004 at nntp4.u.washington.edu>...
> In article <ad052e5c.0406172153.128f765f at posting.google.com>,
> danb_83 at yahoo.com (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
classes.
More information about the Python-list
mailing list