Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo in Mutable Sequence Types documentation. #68511

Closed
eimista mannequin opened this issue May 29, 2015 · 6 comments
Closed

Typo in Mutable Sequence Types documentation. #68511

eimista mannequin opened this issue May 29, 2015 · 6 comments
Assignees
Labels
docs Documentation in the Doc dir performance Performance or resource usage

Comments

@eimista
Copy link
Mannequin

eimista mannequin commented May 29, 2015

BPO 24323
Nosy @rhettinger, @ericvsmith, @1st1

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/rhettinger'
closed_at = <Date 2015-05-31.23:11:35.632>
created_at = <Date 2015-05-29.10:44:17.115>
labels = ['docs', 'invalid', 'performance']
title = 'Typo in Mutable Sequence Types documentation.'
updated_at = <Date 2015-05-31.23:11:35.631>
user = 'https://bugs.python.org/eimista'

bugs.python.org fields:

activity = <Date 2015-05-31.23:11:35.631>
actor = 'rhettinger'
assignee = 'rhettinger'
closed = True
closed_date = <Date 2015-05-31.23:11:35.632>
closer = 'rhettinger'
components = ['Documentation']
creation = <Date 2015-05-29.10:44:17.115>
creator = 'eimista'
dependencies = []
files = []
hgrepos = []
issue_num = 24323
keywords = []
message_count = 6.0
messages = ['244365', '244369', '244379', '244381', '244545', '244546']
nosy_count = 5.0
nosy_names = ['rhettinger', 'eric.smith', 'docs@python', 'yselivanov', 'eimista']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'resource usage'
url = 'https://bugs.python.org/issue24323'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

@eimista
Copy link
Mannequin Author

eimista mannequin commented May 29, 2015

In section (https://docs.python.org/3.5/library/stdtypes.html#mutable-sequence-types) written "s.pop([i])". But this syntax doesn't work.
Maybe the correct notation will be "s.pop(i)"?

@eimista eimista mannequin assigned docspython May 29, 2015
@eimista eimista mannequin added docs Documentation in the Doc dir performance Performance or resource usage labels May 29, 2015
@ericvsmith
Copy link
Member

It's trying to say that "i" is optional, as stated in the footnote. I agree it would be better written as "s.pop(i)", since square brackets are otherwise used in that section as indexing operators. But the footnote should stay, explaining what happens if you omit the parameter.

@1st1
Copy link
Member

1st1 commented May 29, 2015

I think it should be changed to pop(i=-1).

@ericvsmith
Copy link
Member

s.pop(i=-1) doesn't actually work, but I guess it gets the point across.

For 2.7 it's even more confusing, since it includes:
s.index(x[, i[, j]])
and
s.sort([cmp[, key[, reverse]]])

I'd suggest not changing the 2.7 docs.

@rhettinger rhettinger assigned rhettinger and unassigned docspython May 31, 2015
@rhettinger
Copy link
Contributor

There isn't much defense against an overly literal reading of the docs. Both s.pop([i]) and s.pop(i=-1) fail (the latter because pop doesn't take key word arguments and the docstring calls it "index". Also, you would have to define s and i.

FWIW, there is already a note to the effect, "The optional argument i defaults to -1, so that by default the last item is removed and returned."

The [optional_arg] notation is used in a number of places in the docs and docstrings. It is also common with other languages as well and it is used in third-party Python references as well. Eric's initial suggestion of s.pop(i) is simply wrong and would make the docs worse.

As a starting point, realize that the docs have worked well for a lot of people for a long time so there should be a reluctance to change them on a single misreading.

The tutorial also includes the same notation, (see https://docs.python.org/3/tutorial/datastructures.html#more-on-lists ) and as far as I can tell, this has never been an issue.

One other thought, the most common way to call pop() is without an argument (usually, if you use an argument, it is a performance bug). We want to make sure the docs don't suggest otherwise.

Unless there is some strong objection, I recommend leaving the docs as-is.

@ericvsmith
Copy link
Member

I don't feel particularly strongly about it. It's mildly more confusing in the 3.x docs than 2.7 because it's the only use in that section of an optional argument.

I disagree that s.pop(i) is wrong, since it agrees with the "Results" column. But I agree it's not an improvement and we shouldn't encourage it.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

3 participants