Convert long integer to string

Laura Creighton lac at
Thu May 24 06:21:17 EDT 2001

Isaac To Kar Keung <kkto at> writes:
>How about str(val)[:-1]

Assuming you want to do this a lot, this is a bad idea.  Because in
2.0 the L goes away with str, and you will end up truncating your longs.
Bad.  Do this instead.

def l2a(x):
            return repr(long(x))[0:-1]

Then when you convert to 2.0 your programs will keep working.


More information about the Python-list mailing list