python / python/cpython

Undocumented method for "slice" class

Open
#99,121 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Description

Documentation

The "slice" class has a method "indices" that, when given a length of a sequence, will return a tuple with (start, stop, step) that is adjusted for the length of that sequence. This method is completely undocumented

For example,

x=slice(0, 10, -2)
x.indices(5) #This returns (0, 4, -2)
x.indices(10) #This returns (0, 9, -2)
x.indices(100) #This returns (0, 9, -2)

The only example that I could find in any official Python documents is this, there is a single reference to this method at the bottom of the page. However, as of the lastest version of Python, which is 3.11.0 at the time of writing, using this method in a standard installation of CPython still works.

  • PR: gh-99129

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Python documentation page for the slice class linked in the issue and inspect how its methods are documented. Add documentation for slice.indices(), including its length argument, returned tuple, and behavior examples; done means the method is described alongside the class and the examples are accurate.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.