[PYTHON MATRIX-SIG] repr vs. str

Jim Hugunin hugunin@mit.edu
Tue, 20 Aug 1996 09:36:21 -0400

Perry A. Stoll wrote:
> Currently the str and repr functions call the same function
> to print an array object, namely string_repr.  From the manual
> http://www.python.org/doc/ref/node23.html#SECTION00431000000000000000
> __repr__(self)
>      Called by the repr() built-in function and by string conversions
> (reverse or backward quotes) to compute the string
>      representation of an object.
> __str__(self)
>      Called by the str() built-in function and by the print statement
> compute the string representation of an object.
> Seems like print and str should return the same string, which in this
> case would be whatever the array print function is.  I thought repr
> should try to return a string which could be used to reconstruct the
> object and str was purely for human consumption. Is that correct?

This sounds good to me.  I've made your requested change.


MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org