def randrange(self, start, stop=None, step=<NUM_LIT:1>, _int=int, _maxwidth=<NUM_LIT:1><<BPF):
<EOL>istart = _int(start)<EOL>if istart != start:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if stop is None:<EOL><INDENT>if istart > <NUM_LIT:0>:<EOL><INDENT>if istart >= _maxwidth:<EOL><INDENT>return self._randbelow(istart)<EOL><DEDENT>return _int(self.random() * istart)<EOL><DEDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>istop = _int(stop)<EOL>if istop != stop:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>width = istop - istart<EOL>if step == <NUM_LIT:1> and width > <NUM_LIT:0>:<EOL><INDENT>if width >= _maxwidth:<EOL><INDENT>return _int(istart + self._randbelow(width))<EOL><DEDENT>return _int(istart + _int(self.random()*width))<EOL><DEDENT>if step == <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>" % (istart, istop, width))<EOL><DEDENT>istep = _int(step)<EOL>if istep != step:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if istep > <NUM_LIT:0>:<EOL><INDENT>n = (width + istep - <NUM_LIT:1>) // istep<EOL><DEDENT>elif istep < <NUM_LIT:0>:<EOL><INDENT>n = (width + istep + <NUM_LIT:1>) // istep<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if n <= <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if n >= _maxwidth:<EOL><INDENT>return istart + istep*self._randbelow(n)<EOL><DEDENT>return istart + istep*_int(self.random() * n)<EOL>
Choose a random item from range(start, stop[, step]).

        This fixes the problem with randint() which includes the
        endpoint; in Python this is usually not what you want.