Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad example in set tutorial #48820

Closed
jmarter mannequin opened this issue Dec 7, 2008 · 11 comments
Closed

Bad example in set tutorial #48820

jmarter mannequin opened this issue Dec 7, 2008 · 11 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@jmarter
Copy link
Mannequin

jmarter mannequin commented Dec 7, 2008

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']

    @jmarter
    Copy link
    Mannequin Author

    jmarter mannequin commented Dec 7, 2008

    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.

    @jmarter jmarter mannequin assigned birkenfeld Dec 7, 2008
    @jmarter jmarter mannequin added the docs Documentation in the Doc dir label Dec 7, 2008
    @jmarter
    Copy link
    Mannequin Author

    jmarter mannequin commented Dec 7, 2008

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

    @rhettinger
    Copy link
    Contributor

    Fixed r67624.

    @jmarter
    Copy link
    Mannequin Author

    jmarter mannequin commented Jan 24, 2010

    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

    @florentx
    Copy link
    Mannequin

    florentx mannequin commented Jan 24, 2010

    Confirmed in trunk and 3.1

    @florentx florentx mannequin reopened this Jan 24, 2010
    @rhettinger rhettinger assigned rhettinger and unassigned birkenfeld Jan 25, 2010
    @autometa
    Copy link
    Mannequin

    autometa mannequin commented Apr 6, 2010

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

    @jmarter
    Copy link
    Mannequin Author

    jmarter mannequin commented Apr 7, 2010

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

    @l0nwlf
    Copy link
    Mannequin

    l0nwlf mannequin commented Apr 7, 2010

    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'}

    @autometa
    Copy link
    Mannequin

    autometa mannequin commented Apr 7, 2010

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

    @rhettinger
    Copy link
    Contributor

    I'll get to this soon.

    @rhettinger
    Copy link
    Contributor

    Fixed in r83809 and r83810.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants