mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Minor code cleanup
This commit is contained in:
parent
f763a728ad
commit
3051cc3a0d
1 changed files with 4 additions and 4 deletions
|
@ -161,13 +161,13 @@ class Random(_random.Random):
|
||||||
|
|
||||||
## -------------------- integer methods -------------------
|
## -------------------- integer methods -------------------
|
||||||
|
|
||||||
def randrange(self, start, stop=None, step=1, int=int, default=None,
|
def randrange(self, start, stop=None, step=1, int=int, maxwidth=1<<BPF):
|
||||||
maxwidth=1<<BPF):
|
|
||||||
"""Choose a random item from range(start, stop[, step]).
|
"""Choose a random item from range(start, stop[, step]).
|
||||||
|
|
||||||
This fixes the problem with randint() which includes the
|
This fixes the problem with randint() which includes the
|
||||||
endpoint; in Python this is usually not what you want.
|
endpoint; in Python this is usually not what you want.
|
||||||
Do not supply the 'int', 'default', and 'maxwidth' arguments.
|
|
||||||
|
Do not supply the 'int' and 'maxwidth' arguments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This code is a bit messy to make it fast for the
|
# This code is a bit messy to make it fast for the
|
||||||
|
@ -175,7 +175,7 @@ class Random(_random.Random):
|
||||||
istart = int(start)
|
istart = int(start)
|
||||||
if istart != start:
|
if istart != start:
|
||||||
raise ValueError("non-integer arg 1 for randrange()")
|
raise ValueError("non-integer arg 1 for randrange()")
|
||||||
if stop is default:
|
if stop is None:
|
||||||
if istart > 0:
|
if istart > 0:
|
||||||
if istart >= maxwidth:
|
if istart >= maxwidth:
|
||||||
return self._randbelow(istart)
|
return self._randbelow(istart)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue