def irange(*args):
  """
  Similar to range but stop is an inclusive upper bound.
  """
  if len(args) == 0:
    raise TypeError("irange expected at least 1 arguments, got 0")
  elif len(args) == 1:
    stop = args[0]
    start = 0
    step = 1
  elif len(args) == 2:
    start, stop = args
    step = 1
  elif len(args) == 3:
    start, stop, step = args
  else:
    raise TypeError("irange expected at most 3 arguments, got " + str(len(args)))

  if step == 0:
    raise ValueError("irange() step argument must not be zero")

  stop = stop + 1 if step > 0 else stop - 1
  return range(start, stop, step)