On Jan 15, 9:16 pm, Chris Rebert <c...@rebertia.com> wrote:
> On Thu, Jan 15, 2009 at 9:09 PM, flagg <ianand0...@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
>
> Cheers,
> Chris
>
> --
> Follow the path of the Iguana...http://rebertia.com

Ah thank you.  Oversight on my part.  That explains why that if
statement never incremented the counter correctly.  Anything odd about
how I'm converting back and forth between different data types as
often as I am?  Is that common practice is normal programming?
(forgive the beginner questions)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to