Skip to content

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

Closed

Description

@arjunv
mannequin
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']

    Activity

    1. arjunv commented on Apr 3, 2018

      arjunvmannequin
      MannequinAuthor

      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}
      
    2. added
      docsDocumentation in the Doc dir
      on Apr 3, 2018
    3. rhettinger commented on Apr 4, 2018

      @rhettinger
      Contributor

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

    4. rhettinger commented on Apr 4, 2018

      @rhettinger
      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.

    5. 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

    No one assigned

      Labels

      3.7 (EOL)end of life3.8 (EOL)end of lifedocsDocumentation in the Doc dir

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions