Skip to content

Signature of slice is documented incorrectly #107755

@wimglenn

Description

@wimglenn

Documentation

https://docs.python.org/3/library/functions.html#slice currently shows:

class slice(start, stop, step=1)

This was changed from slice(start, stop[, step]) in #96579. That default for step is incorrect. It's correct in a range, but in a slice it actually defaults to None:

>>> slice(1,2).step is None
True

Most code handle step=1 and step=None the same way when receiving a slice, but user defined types implementing __getitem__/__setitem__/__delitem__ aren't obliged to, and the correct default should be documented.

Linked PRs

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions