Skip to content

[3rd Ed][Item 102] Discrepancy in find_closest function example (p. 501) #126

@mingway

Description

@mingway

In Effective Python, 3rd Edition, Item 102 (“Consider Searching Sorted Sequences with bisect”), page 501, the prose says the function should return the index that “is equal to or exceeds” the goal value.

The example implementation right below that line uses the condition:

if goal < value:
    return index

This condition handles only the “greater than” case and ignores the “equal to” case mentioned in the text.

Just wanted to flag this discrepancy.
Thanks for the excellent book!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions