L postfix char on longs - what is the best way to discard it.?

Fred L. Drake, Jr. fdrake at acm.org
Fri Aug 13 09:07:20 EDT 1999


Jim Crumpler writes:
 > query = "... WHERE guff = %s" % repr(long(x))[0:-1]
 > 
 >  -- its ugly when you use alot of longs, but does the job..

  So pack it up in a function:

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

	query = "... WHERE guff = %s" % l2a(x)

  It's still not pretty, but it's more clear than coding it inline
every place you need it!


  -Fred

--
Fred L. Drake, Jr.	     <fdrake at acm.org>
Corporation for National Research Initiatives




More information about the Python-list mailing list