Skip to content

Bad example in set tutorial #48820

Closed
Closed

Description

@jmarter
mannequin
BPO 4570
Nosy @birkenfeld, @rhettinger, @florentx
Files
  • datastructure.patch: tries to improvise upon current patch and makes example more clear
  • datastructures.diff: Updating an example to remove unused assignment. Corrected spacing from previous patch.
  • 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 2010-08-08.01:33:17.550>
    created_at = <Date 2008-12-07.01:10:10.246>
    labels = ['docs']
    title = 'Bad example in set tutorial'
    updated_at = <Date 2010-08-08.01:33:17.549>
    user = 'https://bugs.python.org/jmarter'

    bugs.python.org fields:

    activity = <Date 2010-08-08.01:33:17.549>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2010-08-08.01:33:17.550>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2008-12-07.01:10:10.246>
    creator = 'jmarter'
    dependencies = []
    files = ['16793', '16795']
    hgrepos = []
    issue_num = 4570
    keywords = ['patch']
    message_count = 11.0
    messages = ['77201', '77202', '77204', '98253', '98255', '102497', '102512', '102513', '102517', '102518', '113230']
    nosy_count = 7.0
    nosy_names = ['georg.brandl', 'rhettinger', 'mdcowles', 'jmarter', 'flox', 'l0nwlf', 'autometa']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue4570'
    versions = ['Python 3.1', 'Python 3.2']

    Activity

    1. jmarter commented on Dec 7, 2008

      jmartermannequin
      MannequinAuthor

      On http://docs.python.org/3.0/tutorial/datastructures.html#sets 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.

    2. added
      docs
      on Dec 7, 2008
    3. jmarter commented on Dec 7, 2008

      jmartermannequin
      MannequinAuthor

      Also, I see banana is misspelled on the first output line (line 3).

    4. rhettinger commented on Dec 7, 2008

      @rhettinger
      Contributor

      Fixed r67624.

    5. jmarter commented on Jan 24, 2010

      jmartermannequin
      MannequinAuthor

      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

    6. florentx commented on Jan 24, 2010

      florentxmannequin
      Mannequin

      Confirmed in trunk and 3.1

    7. autometa commented on Apr 6, 2010

      autometamannequin
      Mannequin

      Replaced unused variable assignment with a call to set() for illustrative purposes.

    8. jmarter commented on Apr 7, 2010

      jmartermannequin
      MannequinAuthor

      You may want to add another space before the comment, otherwise it will be the only one not aligned with the others.

    9. l0nwlf commented on Apr 7, 2010

      l0nwlfmannequin
      Mannequin

      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'}
    10. autometa commented on Apr 7, 2010

      autometamannequin
      Mannequin

      I think this change fits well with the rest of the example without having to rework things. Spacing fixed.

    11. rhettinger commented on Apr 7, 2010

      @rhettinger
      Contributor

      I'll get to this soon.

    12. rhettinger commented on Aug 8, 2010

      @rhettinger
      Contributor

      Fixed in r83809 and r83810.

    13. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    docs

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions