Beginner: Data type conversion question
clp2 at rebertia.com
Fri Jan 16 06:16:10 CET 2009
On Thu, Jan 15, 2009 at 9:09 PM, flagg <ianand0204 at gmail.com> wrote:
> I am still fairly new to python and programming in general. My
> question is regarding data conversion, I am working on a script that
> will edit dns zone files, one of the functions i wrote handles
> updating the serial number.
> Our zone files use the date as the first part of the serial and a two
> digit integer as the last two.
> i.e. 2009011501. The next update would be 2009011502, etc
> Here is the function I wrote, I am using dnspython for reading in zone
> files as Zone "objects". Because dnspython's built-in serial updater
> will not work with how we format our serial's, I have to re-write it.
> def checkSerial():
> Checks the current 'date' portion of the serial number and
> checks the current 'counter'(the two digit number at the end of
> the serial number), then returns a complete new serial
> currentDate = time.strftime("%Y""%m""%d", time.localtime())
> for (name, ttl, rdata) in zone.iterate_rdatas(SOA):
> date = str(rdata.serial)[0:8]
> inc = str(rdata.serial)[8:10]
> if date == currentDate:
> int(inc) + 1
The previous line is pointless. It's like having '4+4' as a statement
on its own line. It calculates a value but doesn't change any state or
even use the value. Perhaps you instead meant?:
inc = int(inc) + 1
Follow the path of the Iguana...
More information about the Python-list