Skip to content

.slice() method documentation slightly misleading / inaccurate #14577

Closed
@Meyermagic

Description

@Meyermagic

In:

The documentation states

Fails when start or end point outside the bounds of self

Since slice isn't inclusive, this isn't exactly true. With end == len, end definitely points outside the bounds of self (in the sense that you couldn't do v.get(end), which seems like the obvious interpretation), yet .slice will not fail.

A straightforward reading of the documentation for slice seems to suggest it is inclusive. Maybe write

Returns a slice of self from start up to, but not including, end.

or

Returns a slice of self spanning the interval [start, end).
Or something else (since both of these are kinda awkward and don't fix the next sentence).

I feel like slice's documentation should make the semantics of the method as clear and unambiguous as possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions