mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-42222: Modernize integer test/conversion in randrange() (#23064)
This commit is contained in:
parent
1031f23fc3
commit
a9621bb301
4 changed files with 81 additions and 11 deletions
|
|
@ -135,6 +135,15 @@ Functions for integers
|
|||
values. Formerly it used a style like ``int(random()*n)`` which could produce
|
||||
slightly uneven distributions.
|
||||
|
||||
.. deprecated:: 3.10
|
||||
The automatic conversion of non-integer types to equivalent integers is
|
||||
deprecated. Currently ``randrange(10.0)`` is losslessly converted to
|
||||
``randrange(10)``. In the future, this will raise a :exc:`TypeError`.
|
||||
|
||||
.. deprecated:: 3.10
|
||||
The exception raised for non-integral values such as ``range(10.5)``
|
||||
will be changed from :exc:`ValueError` to :exc:`TypeError`.
|
||||
|
||||
.. function:: randint(a, b)
|
||||
|
||||
Return a random integer *N* such that ``a <= N <= b``. Alias for
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue