Skip to content

Make random.sample's k argument optional #96545

Closed as not planned
Closed as not planned
@Gouvernathor

Description

@Gouvernathor

Feature or enhancement

The random.sample function takes a k argument, I want to make it default to the length of the sequence.

Pitch

It would make a copy-shuffle (as opposed to the in-place shuffle done by random.shuffle) just as simple as one function call. It would also allow easier of random.sample in a functional programming fashion, by avoiding the need to create a variable containing the population variable prior to calling the function.
In other words, random.sample would be to random.shuffle what sorted is to str.sort.

Previous discussion

https://discuss.python.org/t/making-random-samples-k-argument-optional/

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions