Skip to content

Conversation

@hyperkai
Copy link

@hyperkai hyperkai commented Oct 15, 2025

I corrected the meaning of the words positive numbers used in the section What’s a negative index?.

In the original explanation, the words positive numbers are used to cover the numbers greater than or equal to zero but actually, zero is neither a positive number nor negative number. Positive numbers are only the numbers greater than zero.

So as the main change, I added the words signed numbers to cover 3 types of numbers zero, positive numbers and negative numbers in the section What’s a negative index?.


📚 Documentation preview 📚: https://cpython-previews--140176.org.readthedocs.build/

I added the words `signed numbers` to cover zero, positive numbers and negative numbers in the section **What’s a negative index?**.
@python-cla-bot
Copy link

python-cla-bot bot commented Oct 15, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news labels Oct 15, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Oct 15, 2025
Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While yes, 0 is not a positive number, I am -0 on this as I do not think this is the place to make such a distinction. It has no benefit to the explanation (it has no impact on the important bit: "0 is the first index"), and IMO, unnecessarily extends it.

index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``.

Using negative indices can be very convenient. For example ``S[:-1]`` is all of
Using negative indices can be very convenient. For example ``S[:-1]`` is all of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change.

positive numbers 0 is the first index 1 is the second index and so forth. For
negative indices -1 is the last index and -2 is the penultimate (next to last)
index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``.
Python sequences are indexed with signed numbers (zero, positive numbers and negative numbers). For example, 0 is the 1st index and for positive indices, 1 is the 2nd index, 2 is the 3rd index and so forth. For
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines should be wrapped to 79 characters.

@StanFromIreland
Copy link
Member

CC @AA-Turner, I am interested to hear your opinion on this.

@StanFromIreland StanFromIreland changed the title I corrected the meaning of the words **positive numbers** used in the section **What’s a negative index?**. Correct usage of "positive numbers" in FAQ section "What’s a negative index?". Oct 15, 2025
Comment on lines +1179 to +1181
Python sequences are indexed with signed numbers (zero, positive numbers and negative numbers). For example, 0 is the 1st index and for positive indices, 1 is the 2nd index, 2 is the 3rd index and so forth. For
negative indices, -1 is the last index, -2 is the penultimate (next to last)
index and so forth. Think of ``seq[-n]`` as the same as ``seq[len(seq)-n]``.
Copy link
Contributor

@skirpichev skirpichev Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that old text was too bad. But you if considered to change that - please use more common terminology. What's "signed numbers" are? Integers, right?

You could mention that for non-negative indexes it's meaning is just usual zero-based indexing of arrays. For negative indexes, the index i is relative to the end of sequence, i.e.: len(seq) + i is substituted.

@hyperkai hyperkai closed this by deleting the head repository Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants