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

Fix instances in documentation where dictionaries are referenced as unordered #77399

Closed
arjunv mannequin opened this issue Apr 3, 2018 · 3 comments
Closed

Fix instances in documentation where dictionaries are referenced as unordered #77399

arjunv mannequin opened this issue Apr 3, 2018 · 3 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes docs Documentation in the Doc dir

Comments

@arjunv
Copy link
Mannequin

arjunv mannequin commented Apr 3, 2018

BPO 33218
Nosy @rhettinger, @arjunv
Superseder
  • bpo-32337: Dict order is now guaranteed, so add tests and doc for it
  • 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 = None
    closed_at = <Date 2018-04-04.04:24:58.573>
    created_at = <Date 2018-04-03.20:26:04.510>
    labels = ['3.7', '3.8', 'docs']
    title = 'Fix instances in documentation where dictionaries are referenced as unordered'
    updated_at = <Date 2018-04-04.04:24:58.572>
    user = 'https://github.com/arjunv'

    bugs.python.org fields:

    activity = <Date 2018-04-04.04:24:58.572>
    actor = 'methane'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2018-04-04.04:24:58.573>
    closer = 'methane'
    components = ['Documentation']
    creation = <Date 2018-04-03.20:26:04.510>
    creator = 'arjunv'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33218
    keywords = []
    message_count = 3.0
    messages = ['314892', '314914', '314915']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'docs@python', 'arjunv']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '32337'
    type = None
    url = 'https://bugs.python.org/issue33218'
    versions = ['Python 3.7', 'Python 3.8']

    @arjunv
    Copy link
    Mannequin Author

    arjunv mannequin commented Apr 3, 2018

    In python 3.6 (and above hopefully), dictionary keys are going to be ordered, while their documentation still reference them as being unordered.

    https://docs.python.org/3/tutorial/datastructures.html#dictionaries

    1: It is best to think of a dictionary as an unordered set of key: value pairs,...

    2: Performing list(d.keys()) on a dictionary returns a list of all the keys used in the dictionary, in arbitrary order..

    The examples should also be changed to reflect the same:

    >>> tel = {'jack': 4098, 'sape': 4139}
    >>> tel['guido'] = 4127
    >>> tel
    {'sape': 4139, 'guido': 4127, 'jack': 4098}
    >>> tel['jack']
    4098
    >>> del tel['sape']
    >>> tel['irv'] = 4127
    >>> tel
    {'guido': 4127, 'irv': 4127, 'jack': 4098}
    >>> list(tel.keys())
    ['irv', 'guido', 'jack']
    >>> sorted(tel.keys())
    ['guido', 'irv', 'jack']
    >>> 'guido' in tel
    True
    >>> 'jack' not in tel
    False
    
    >>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])
    {'sape': 4139, 'guido': 4127, 'jack': 4098}
    
    >>> dict(sape=4139, guido=4127, jack=4098)
    {'sape': 4139, 'guido': 4127, 'jack': 4098}
    

    @arjunv arjunv mannequin added 3.7 (EOL) end of life 3.8 only security fixes labels Apr 3, 2018
    @arjunv arjunv mannequin assigned docspython Apr 3, 2018
    @arjunv arjunv mannequin added the docs Documentation in the Doc dir label Apr 3, 2018
    @rhettinger
    Copy link
    Contributor

    Would you like to make a pull request or do you prefer for me to assign it to someone else?

    @rhettinger
    Copy link
    Contributor

    Also check the 3.7 docs to see if this work has already been done.

    It's unlikely that the 3.6 docs will change because it is considered a non-guaranteed implementation detail for 3.6.

    @methane methane closed this as completed Apr 4, 2018
    @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
    3.7 (EOL) end of life 3.8 only security fixes docs Documentation in the Doc dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants