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

M.-A. Lemburg mal@lemburg.com
Sun, 26 Dec 1999 23:29:28 +0100


Greg Stein wrote:
> 
> On Fri, 24 Dec 1999, M.-A. Lemburg wrote:
> > 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'.

Ah, ok... scanning the patches: they don't provide an externed
C interface... I would like to have such a beast if possible
(basically, the new long_format() as PyLong_AsString()).

> 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]
>   ]

Your above example will effectively divide the long value by 10
which will probably break things in very subtle ways... hmm, this
change ought to be made *very* visible to people upgrading to
1.6, IMHO.

I'll fix mxODBC to only truncate the string value iff
the 'L' is present.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                     5 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/