[Python-Dev] str(1L) -> '1' ?

Greg Stein gstein@lyra.org
Fri, 24 Dec 1999 12:13:50 -0800 (PST)


On Fri, 24 Dec 1999, M.-A. Lemburg wrote:
> Guido van Rossum wrote:
> > [Jim F]
> > > In November there was an interesting discussion on comp.lang.python
> > > about the meaning of __str__ and __repr__.  One tidbit that came out
> > > of this discussion was that __str__ for longs should drop the trailing
> > > 'L'. Was there a decision on this? I'd really like this to happen.
> > 
> > Yes, I'd like it to happen.  I'd also like repr() of a float to return
> > the full precision (using the "%.17g" sprintf format).
> 
> While we're at it: how about adding a PyLong_AsString() API
> to the C interface ? I currently use PyObject_Str() in mxODBC
> and then slice off the 'L' -- not very elegant. A PyLong_AsString()
> API would much better suit the task.

Fred just checked in a change yesterday. PyObject_Str() on a Long no
longer includes the 'L'.

You're going to need to update your code :-)
[ I've got some here and there to fix, too, with the idiom:
     if type(v) is type(1L): return str(v)[:-1]
  ]

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/