def digitsToInt(digits, base=10):
  """
  Convert list of digits (in specified base) to an integer
  """
  # first get an iterator to digits
  if not hasattr(digits, 'next'):
    # digits is an iterator
    digits = iter(digits)
  # now loop through digits, updating num
  num = next(digits)
  for d in digits:
    num *= base
    num += d
  return num