__str__ vs. __repr__
boncelet at udel.edu
Mon Nov 8 05:09:14 EST 1999
Tim Peters wrote:
> David Ascher suggested that str(long) drop the trailing "L", and that's a
> good example. The "L" is appropriate for repr(), for so long as Python
> maintains such a sharp distinction between ints and longs, but is really of
> no help to most users most of the time.
On the dissenting side, I find the "L" useful (just as I find the
difference between 1 and '1' useful. Consider the following:
>>> a,b = 2L, 2
Traceback (innermost last):
File "<stdin>", line 1, in ?
OverflowError: integer pow()
Without the "L", it is not at all clear why a**32 works and b**32 fails.
Charles Boncelet <boncelet at udel.edu>
University of Delaware
Newark DE 19716 USA
More information about the Python-list