Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Labels
3.13bugs and security fixes3.14bugs and security fixesrelease-blockerstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@andersk

Description

@andersk

Bug report

Bug description:

In the specification for the newpython -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 (viarandom.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 lengthN starting from0.0, not a range of lengthN - 1.0 starting from1.0.

(Note that this is completely distinct from the debate about whether it’s more natural to selectintegers from[1, …, N] or[0, …, N - 1], as at least those are both ranges of lengthN.)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp