[Zope] string formatting
jeff.peterson at crary.com
Fri Aug 13 14:03:54 EDT 2010
To be more flexible it should probably look more like this:
id, count = (s[:1], s[1:])
count = string.zfill(str(int(count) + 1), len(count))
return '%s%s' % (id, count)
That way even 'B00000006' would get incremented properly.
Jeffrey D Peterson
Crary Industries, Inc.
From: zope-bounces at zope.org [mailto:zope-bounces at zope.org] On Behalf Of Ebbe Kvist
Sent: Friday, August 13, 2010 11:17 AM
To: zope at zope.org
Subject: [Zope] string formatting
I want to process a variable, signum2, which is picked up from a MySQL database. The content of the variable is
The aim is to process this variable so the result will be
"B007" and it will then be saved as part of a new record in the database.
The core process is to increment the integer part of the variable "006" with 1.
I have successfully done this incrementation but I have not been able to create a new
correct content for the new varable new_xyz.
<dtml-call "REQUEST.set('signumfix2', _.int(signumfix2)+1)">
How can I from here create the correct content of the new variable? I need to bring the "B" part
with me and then the incremented integer part formatted with two preceeding zeroes. Does anyone know?
Hitta kärleken med hjälp av vårt matchningstest - Klicka här!<http://spray.matchaffinity.se/?mtcmk=614114>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Zope