Convert long integer to string

Laura Creighton lac at cd.chalmers.se
Thu May 24 12:21:17 CEST 2001


Isaac To Kar Keung <kkto at csis.hku.hk> 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.

Laura





More information about the Python-list mailing list