__str__ vs. __repr__
mal at lemburg.com
Fri Nov 5 12:24:03 CET 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.
If you should really plan to do this, please add a new PyLong_AsString()
API, so that extensions can query the long int value using the
string format (probably the most portable way of passing long int
values from one implementation to another). A PyLong_FromString() API
would be a nice complement to PyLong_AsString()... it could use the
code from the builtin long() as engine.
I'm currently using PyObject_Str() on Python long integers to
have converted to strings and chop off the trailing 'L' "by hand".
Not really very elegant, but it works :-)
Y2000: 56 days left
Python Pages: http://www.lemburg.com/python/
More information about the Python-list