Command-line interface for the random module
#118131
Labels
3.13
bugs and security fixes
stdlib
Python modules in the Lib dir
type-feature
A feature request or enhancement
Feature or enhancement
Proposal:
Many stdlib libraries have a simple CLI:
Some of my favourites:
It would be useful to add a CLI to
randomto be randomly select a choice (usingrandom.choice):We can also print a random number:
random.randint)random.uniform).For example:
Also with explicit arguments:
This isn't a Python-specific tool, like
pdborpickletools, but a generally useful tool likehttp.serveranduuid. I can't find an existing cross-platform tool for this. Linux hasshufto return a random choice, but it's not natively available in macOS (it's part of a Homebrew package) or Windows (uutilscan be installed using Scoop). There's also anum-utilspackage for Unix to print a random integer.For me, just the random choice is the most important, but I can see at least picking a random integer is also useful, like a dice throw.
Currently,
python -m randomgenerates some sample test output; if we still need it I propose moving it topython -m random --test.Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Linked PRs
randommodule #118132The text was updated successfully, but these errors were encountered: