def computeChecksum(self, arg):
      """ Compute the checksum of bar code """
      # UPCA/EAN13
      weight=[1,3]*6
      magic=10
      sum = 0
      
      for i in range(12):         # checksum based on first 12 digits.
         sum = sum + int(arg[i]) * weight[i]
      z = ( magic - (sum % magic) ) % magic
      if z < 0 or z >= magic:
         return None
      return z
 Compute the checksum of bar code 
recipes/Python/426069_EAN_Bar_code_image_generator/recipe-426069.py