GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `python -m random --float N` should pick a float between 0 and N, not 1 and N · Issue #123968 · python/cpython

python -m random --float N should pick a float between 0 and N, not 1 and N #123968

New issue
Copy link
New issue
Copy link
Closed
Closed
python -m random --float N should pick a float between 0 and N, not 1 and N#123968
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@andersk
andersk
opened on Sep 11, 2024
Issue body actions

Bug report

Bug description:

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.0
1.883974829952927
$ python -m random 2.0
1.034610672623156
$ python -m random 2.0
1.3676261878147473
$ python -m random 2.0
1.1875340810783404
$ python -m random 2.0
1.6148479875565644
$ python -m random 1.0
1.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.)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

  • gh-123968: Fix lower bound for python -m random --float #123971
  • [3.13] gh-123968: Fix lower bound for python -m random --float (GH-123971) #124009
  • gh-123968: fix -f/--float command line option description #124517
  • [3.13] gh-123968: fix -f/--float command line option description (GH-124517) #124523
Reacted by Shantanu, Kirill Podoprigora and Kamil Monicz

Activity

  1. andersk
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 11, 2024
  2. andersk
    added a commit that references this issue on Sep 11, 2024

    pythongh-123968: Fix lower bound for `python -m random --float`

    98fb826
  3. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Sep 11, 2024
  4. andersk
    added a commit that references this issue on Sep 11, 2024

    pythongh-123968: Fix lower bound for `python -m random --float`

    14e414a
  5. hauntsaninja
    added
    release-blocker
    on Sep 12, 2024
  6. ezio-melotti
    added this to Release and Deferred blockers 🚫on Sep 12, 2024
  7. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on Sep 12, 2024
  8. hauntsaninja commented on Sep 12, 2024

    @hauntsaninja
    hauntsaninja
    on Sep 12, 2024
    Contributor
    More actions

    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

    Reacted by Kirill Podoprigora and Hugo van Kemenade
  9. hauntsaninja
    added
    3.13only security fixesonly security fixes
    on Sep 12, 2024
  10. Eclips4
    added
    3.14bugs and security fixesbugs and security fixes
    on Sep 12, 2024
  11. hugovk
    added a commit that references this issue on Sep 12, 2024

    gh-123968: Fix lower bound for `python -m random --float` (#123971)

    a362c41
  12. miss-islington
    added a commit that references this issue on Sep 12, 2024

    pythongh-123968: Fix lower bound for `python -m random --float` (pyth…

    d556d27
  13. Yhg1s
    added a commit that references this issue on Sep 23, 2024

    [3.13] gh-123968: Fix lower bound for `python -m random --float` (GH-…

    7b8affa
  14. hugovk commented on Sep 23, 2024

    @hugovk
    hugovk
    on Sep 23, 2024
    Member
    More actions

    Merged and backported, thanks!

  15. hugovk
    closed this as completedon Sep 23, 2024
  16. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on Sep 23, 2024
  17. nanjekyejoannah
    added a commit that references this issue on Sep 25, 2024

    gh-123968: fix -f/--float command line option description (#124517)

    f8651a2
  18. miss-islington
    added a commit that references this issue on Sep 25, 2024

    pythongh-123968: fix -f/--float command line option description (pyth…

    6fed94a
  19. Yhg1s
    added a commit that references this issue on Sep 26, 2024

    [3.13] gh-123968: fix -f/--float command line option description (GH-…

    6607c72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Release and Deferred blockers 🚫
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.