Skip to content

Bisect docs define a function that uses a list as a default argument #145269

@ngoldbaum

Description

@ngoldbaum

Documentation

The docs for bisect.bisect use a kind of funky pattern with a list as a default argument:

https://docs.python.org/3/library/bisect.html#examples

Image

Using a list as a default argument is a really common pattern beginners think will be helpful but usually isn't due to the way default arguments are bound to the class object instead of instances. It's also distracting for more advanced readers who are trained to spot this pattern in code reviews.

IMO this example would be clearer if grade accepted no arguments besides score and the defaults were inlined.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions