'randrange([start,] stop[, step]):
Return a randomly-selected element from range(start, stop, step).'

def randrange(self, *args):

    if (len(args) == 3):
        (start, stop, step) = args
    elif (len(args) == 2):
        (start, stop) = args
        step = 1
    elif (len(args) == 1):
        (stop,) = args
        start = 0
        step = 1
    else:
        raise TypeError(('randrange    expected    at    most    3    arguments,    got    %d' % (len(args),)))
    if ((not isinstance(start, (int, long))) or (not isinstance(stop, (int, long))) or (not isinstance(step, (int, long)))):
        raise TypeError('randrange    requires    integer    arguments')
    if (step == 0):
        raise ValueError('randrange    step    argument    must    not    be    zero')
    num_choices = ceil_div((stop - start), step)
    if (num_choices < 0):
        num_choices = 0
    if (num_choices < 1):
        raise ValueError(('empty    range    for    randrange(%r,    %r,    %r)' % (start, stop, step)))
    r = num_choices
    while (r >= num_choices):
        r = self.getrandbits(size(num_choices))
    return (start + (step * r))
