Re: [OVC-demo-team] BRP status report

From: David Mertz <voting-project_at_gnosis_dot_cx>
Date: Mon Mar 15 2004 - 23:50:56 CST

On Tuesday, March 16, 2004, at 12:27 AM, David Mertz wrote:
> ballotId = "%04d" % ids[i]

I was just looking through evm2003.utils.convert.votes2digits() to see
if I could figure out what might be going wrong in
regarding the barcode. I don't have the answer yet, but I noticed a
similar opportunity for simplification. Where the function ends with:

     digits = str(todecimal(bits))
         # The string must have exacly 36 digits - insert leading zeroes
     for i in range(36-len(digits)):
         digits = "0" + digits
     return ballotno + digits

We could simplify as:

     return "%s036d%" % (ballotno, todecimal(bits))

Or if that one is too oblique, this is a bit more explicit:

        digits = str(todecimal(bits)).zfill(36)
        return ballotno + digits

Incidentally, evm2003.utils.convert.todecimal() can also use some
Python standard functions:

     def todecimal(bin):
     """Convert a binary number to decimal.

         bin: The binary number as a list of bits
     return int("".join(bin), 2)

Some of this formatting and bit-twiddling stuff in Python takes a bit
of familiarity, and is easy to overlook.

Dred Scott 1857; Santa Clara 1876; Plessy 1892;
Korematsu 1944; Eldred 2003
= The content of this message, with the exception of any external 
= quotations under fair use, are released to the Public Domain    
Received on Thu Apr 1 02:40:27 2004

This archive was generated by hypermail 2.1.8 : Thu Apr 01 2004 - 02:40:36 CST