[docs] Ambiguity in python3.4 tutorial

Borden Rhodes jrvp at bordenrhodes.com
Tue Jan 6 08:07:43 CET 2015


Good morning,

In https://docs.python.org/3/tutorial/introduction.html#lists, there
is an ambiguity. In section 3.1.3:
Paragraph 3 reads: "All slice operations return a new list containing
the requested elements."
Paragraph 7 reads: "Assignment to slices is also possible, and this
can even change the size of the list or clear it entirely."

For a new user like me, paragraph 3 suggests that assigning anything
to a slice would modify the new list, not the original list. Using the
example in the tutorial, if letters = [a, b, c, d, e, f, g], and
letters[2:5] returns the slice [c, d, e], then I would expect, under
paragraph 3, that letters[2:5] = [C, D, E] would yield letters[2:5] =
[C, D, E], since the array [C, D, E] would overwrite the new, 3
element array created by letters[2:5] which, under paragraph 3, is a
copy of a slice of letters[] and not letters[] itself.

As I said, I'm just starting out (but have experience in C++, Java &
PHP), so I haven't checked the language specification for
clarification. Perhaps the documentation could either remove the word
'all' in paragraph 3 so that it isn't as absolute or perhaps provide a
reference or explanation in paragraph 7 which explains why my
interpretation is incorrect.

Please let me know if I can provide any assistance or clarification.

With thanks,

Borden Rhodes


More information about the docs mailing list