This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Small correction in set code sample
Type: Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mariatta Nosy List: Mariatta, docs@python, mcocdawc, rhettinger, terry.reedy
Priority: low Keywords:

Created on 2017-05-09 08:47 by mcocdawc, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2081 merged python-dev, 2017-06-10 17:00
PR 2085 merged Katherine Michel, 2017-06-10 20:23
Messages (6)
msg293291 - (view) Author: Oskar Weser (mcocdawc) Date: 2017-05-09 08:47
There is a code example about the set type found under:
https://docs.python.org/3/tutorial/datastructures.html

It reads as:
```
>>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
>>> print(basket)                      # show that duplicates have been removed
{'orange', 'banana', 'pear', 'apple'}
>>> 'orange' in basket                 # fast membership testing
True
>>> 'crabgrass' in basket
False

>>> # Demonstrate set operations on unique letters from two words
...
>>> a = set('abracadabra')
>>> b = set('alacazam')
>>> a                                  # unique letters in a
{'a', 'r', 'b', 'c', 'd'}
>>> a - b                              # letters in a but not in b
{'r', 'd', 'b'}
>>> a | b                              # letters in either a or b
```

I read "either a or b" as "a .EXOR. b". Shouldn't it be:
```
>>> a | b                              # letters in a or b
```
I don't speak English as a native language, so perhaps I am wrong.
msg293293 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-05-09 09:10
ISTM the result of the expression makes the meaning clear:

    >>> a | b
    {'r', 'l', 'b', 'c', 'z', 'd', 'a', 'm'}

That said, the text might be a little clearer like this:

   # letters in a or b or both
msg293575 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-12 21:39
English 'or' remains ambiguous, and often exclusive, even without 'either'.  Hence jokes like
  Parent: "Cake or pie?"
  Smart kid: "Both!"
I agree with replacing 'either' with 'or both'.
msg295658 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 19:19
New changeset ca816153445cba3baec15f7e890c71abfe495340 by Mariatta (KatherineMichel) in branch 'master':
bpo-30312: Small correction in datastructures set code sample (GH-2081)
https://github.com/python/cpython/commit/ca816153445cba3baec15f7e890c71abfe495340
msg295664 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 20:33
New changeset 865ed9ea67cf0d8a8dead91f3eac527553d92284 by Mariatta (KatherineMichel) in branch '3.6':
bpo-30312: Small correction in datastructures set code sample (GH-2081) (GH-2085)
https://github.com/python/cpython/commit/865ed9ea67cf0d8a8dead91f3eac527553d92284
msg295665 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 20:35
Documentation has been updated, and backported to 3.6.
Thanks :)
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74497
2017-06-10 20:35:18Mariattasetstatus: open -> closed
resolution: fixed
messages: + msg295665

stage: backport needed -> resolved
2017-06-10 20:33:59Mariattasetmessages: + msg295664
2017-06-10 20:23:16Katherine Michelsetpull_requests: + pull_request2149
2017-06-10 19:22:30Mariattasetstage: backport needed
2017-06-10 19:19:11Mariattasetmessages: + msg295658
2017-06-10 17:00:49python-devsetpull_requests: + pull_request2145
2017-05-12 21:43:23rhettingersetversions: - Python 3.5
2017-05-12 21:39:51terry.reedysetnosy: + terry.reedy
messages: + msg293575
2017-05-09 09:10:11rhettingersetpriority: normal -> low

nosy: + Mariatta, rhettinger
messages: + msg293293

assignee: docs@python -> Mariatta
2017-05-09 08:47:27mcocdawccreate