diff --git a/Lib/random.py b/Lib/random.py --- a/Lib/random.py +++ b/Lib/random.py @@ -165,18 +165,19 @@ ## -------------------- integer methods ------------------- - def randrange(self, start, stop=None, step=1, int=int): + def randrange(self, start, stop=None, step=1, _int=int): """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. - Do not supply the 'int' argument. + Do not supply the '_int' argument. It is defaulted to int built-in at + function definition time, purely for optimization purposes. """ # This code is a bit messy to make it fast for the # common case while still doing adequate error checking. - istart = int(start) + istart = _int(start) if istart != start: raise ValueError("non-integer arg 1 for randrange()") if stop is None: @@ -185,7 +186,7 @@ raise ValueError("empty range for randrange()") # stop argument supplied. - istop = int(stop) + istop = _int(stop) if istop != stop: raise ValueError("non-integer stop for randrange()") width = istop - istart @@ -195,7 +196,7 @@ raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width)) # Non-unit step argument supplied. - istep = int(step) + istep = _int(step) if istep != step: raise ValueError("non-integer step for randrange()") if istep > 0: @@ -216,7 +217,7 @@ return self.randrange(a, b+1) - def _randbelow(self, n, int=int, maxsize=1<