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

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy