L postfix char on longs - what is the best way to discard it.?
Jim.Crumpler at unicity.com.au
Fri Aug 13 14:22:22 CEST 1999
Hi folks - I'm batting to find a nice clean way to remove the 'L' from long
repr strings .. (eg, my SQL queries end up like "SELECT * FROM blah WHERE
guff = 23423L"..)
I can fiddle with every bit of my code that attempts to display a long, such
query = "... WHERE guff = %s" % repr(long(x))[0:-1]
-- its ugly when you use alot of longs, but does the job..
I can bugger around with long_format() to remove the postix 'L' altogether,
or build a % substitution to print a long without the L - uglier for
distribution, but nice for writing code - I have no idea what repercussions
this has on the library code - probably bad.. I'm assuiming the actual
reason for the 'L' is so a string could be then fed back as a literal
without overflow the default integer conversion. Couldn't the integer
conversion build a long on overflow, or would that get uglier?
Does anyone have some suggestions on better methods?
More information about the Python-list