Issue 30312: Small correction in set code sample (original) (raw)
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.
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: