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.

Title: Bad example in set tutorial
Type: Stage: patch review
Components: Documentation Versions: Python 3.1, Python 3.2
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: autometa, flox, georg.brandl, jmarter, l0nwlf, mdcowles, rhettinger
Priority: normal Keywords: patch

Created on 2008-12-07 01:10 by jmarter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
datastructure.patch l0nwlf, 2010-04-07 02:50 tries to improvise upon current patch and makes example more clear
datastructures.diff autometa, 2010-04-07 04:51 Updating an example to remove unused assignment. Corrected spacing from previous patch.
Messages (11)
msg77201 - (view) Author: John Marter (jmarter) Date: 2008-12-07 01:10
On there is
the following section in the section on sets

>>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
>>> print(basket)
{'orange', 'bananna', 'pear', 'apple'}
>>> fruit = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> fruit = set(basket)               # create a set without duplicates
>>> fruit
{'orange', 'pear', 'apple', 'banana'}

The third command should be an assignment to basket rather than fruit.
msg77202 - (view) Author: John Marter (jmarter) Date: 2008-12-07 01:12
Also, I see banana is misspelled on the first output line (line 3).
msg77204 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-12-07 01:21
Fixed r67624.
msg98253 - (view) Author: John Marter (jmarter) Date: 2010-01-24 22:04
I see that the spelling of banana has been fixed but what is the purpose of assigning fruit and then immediately reassigning it another value without even looking at the first assignment?

>>> fruit = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> fruit = set(basket)               # create a set without duplicates
msg98255 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-24 22:39
Confirmed in trunk and 3.1
msg102497 - (view) Author: autometa (autometa) Date: 2010-04-06 21:25
Replaced unused variable assignment with a call to set() for illustrative purposes.
msg102512 - (view) Author: John Marter (jmarter) Date: 2010-04-07 02:31
You may want to add another space before the comment, otherwise it will be the only one not aligned with the others.
msg102513 - (view) Author: Shashwat Anand (l0nwlf) Date: 2010-04-07 02:50
I guess giving fruit, the set of unique fruit a different name makes it more clear. Comments alignment fixed.

>>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
>>> print(basket)
{'orange', 'bananna', 'pear', 'apple'}
>>> fruit = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> uniquefruit = set(fruit)               # create a set without duplicates
>>> uniquefruit
{'orange', 'pear', 'apple', 'banana'}
msg102517 - (view) Author: autometa (autometa) Date: 2010-04-07 04:51
I think this change fits well with the rest of the example without having to rework things.  Spacing fixed.
msg102518 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-04-07 05:57
I'll get to this soon.
msg113230 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-08-08 01:33
Fixed in r83809 and r83810.
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48820
2010-08-08 01:33:17rhettingersetstatus: open -> closed
resolution: accepted
messages: + msg113230
2010-04-23 17:42:14ezio.melottisetpriority: normal
nosy: + mdcowles

stage: needs patch -> patch review
2010-04-07 06:02:28autometasetfiles: - datastructures.diff
2010-04-07 05:57:07rhettingersetmessages: + msg102518
2010-04-07 04:51:05autometasetfiles: + datastructures.diff

messages: + msg102517
2010-04-07 02:50:42l0nwlfsetfiles: + datastructure.patch
nosy: + l0nwlf
messages: + msg102513

2010-04-07 02:31:19jmartersetmessages: + msg102512
2010-04-06 21:25:33autometasetfiles: + datastructures.diff

nosy: + autometa
messages: + msg102497

keywords: + patch
2010-01-25 02:22:56rhettingersetassignee: georg.brandl -> rhettinger
2010-01-24 22:39:03floxsetstatus: closed -> open

versions: + Python 3.1, Python 3.2
nosy: + flox

messages: + msg98255
resolution: fixed -> (no value)
stage: needs patch
2010-01-24 22:04:37jmartersetmessages: + msg98253
2008-12-07 01:21:42rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg77204
nosy: + rhettinger
2008-12-07 01:12:16jmartersetmessages: + msg77202
2008-12-07 01:10:10jmartercreate