You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
python -m random --float N should pick a float between 0 and N, not 1 and N #123968
In the specification for the new python -m random CLI for 3.13 (#118131), the proposed behavior was
if it's a float, print a random float between 0 and the input (via random.uniform).
However, what was actually implemented (#118132, cc @hugovk) was
$ python -m random --help[…] -f, --float N print a random floating-point number between 1 and N inclusive
$ python -m random 2.01.883974829952927
$ python -m random 2.01.034610672623156
$ python -m random 2.01.3676261878147473
$ python -m random 2.01.1875340810783404
$ python -m random 2.01.6148479875565644
$ python -m random 1.01.0
This is surprising and not helpful. Everyone will expect a range of length N starting from 0.0, not a range of length N - 1.0 starting from 1.0.
(Note that this is completely distinct from the debate about whether it’s more natural to select integers from [1, …, N] or [0, …, N - 1], as at least those are both ranges of length N.)
Activity
pythongh-123968: Fix lower bound for `python -m random --float`
pythongh-123968: Fix lower bound for `python -m random --float`
hauntsaninja commentedon Sep 12, 2024
To avoid compatibility issues, it would be good to fix this in 3.13.0 so I added release-blocker. Please let me know if that's inappropriate
gh-123968: Fix lower bound for `python -m random --float` (#123971)
pythongh-123968: Fix lower bound for `python -m random --float` (pyth…
[3.13] gh-123968: Fix lower bound for `python -m random --float` (GH-…
hugovk commentedon Sep 23, 2024
Merged and backported, thanks!
gh-123968: fix -f/--float command line option description (#124517)
pythongh-123968: fix -f/--float command line option description (pyth…
[3.13] gh-123968: fix -f/--float command line option description (GH-…