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

"Evaluation order" doc section is wrong about dicts #60981

Closed
ezio-melotti opened this issue Dec 25, 2012 · 2 comments
Closed

"Evaluation order" doc section is wrong about dicts #60981

ezio-melotti opened this issue Dec 25, 2012 · 2 comments
Assignees
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@ezio-melotti
Copy link
Member

BPO 16777
Nosy @ezio-melotti, @cjerdonek
Superseder
  • bpo-11205: Evaluation order of dictionary display is different from reference manual.
  • 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/ezio-melotti'
    closed_at = <Date 2012-12-25.14:41:50.008>
    created_at = <Date 2012-12-25.13:54:47.930>
    labels = ['type-feature', 'docs']
    title = '"Evaluation order" doc section is wrong about dicts'
    updated_at = <Date 2012-12-25.14:41:50.006>
    user = 'https://github.com/ezio-melotti'

    bugs.python.org fields:

    activity = <Date 2012-12-25.14:41:50.006>
    actor = 'ezio.melotti'
    assignee = 'ezio.melotti'
    closed = True
    closed_date = <Date 2012-12-25.14:41:50.008>
    closer = 'ezio.melotti'
    components = ['Documentation']
    creation = <Date 2012-12-25.13:54:47.930>
    creator = 'ezio.melotti'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 16777
    keywords = []
    message_count = 2.0
    messages = ['178127', '178129']
    nosy_count = 2.0
    nosy_names = ['ezio.melotti', 'chris.jerdonek']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '11205'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue16777'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @ezio-melotti
    Copy link
    Member Author

    http://docs.python.org/2/reference/expressions.html#evaluation-order
    says that the dicts are evaluated in this order:
    {expr1: expr2, expr3: expr4}

    however each value is evaluated before the respective key:
    def f(x):
    print(x)
    return x

    {f('k1'): f('v1'), f('k2'): f('v2')}

    v1
    k1
    v2
    k2
    {'k1': 'v1', 'k2': 'v2'}

    @ezio-melotti ezio-melotti self-assigned this Dec 25, 2012
    @ezio-melotti ezio-melotti added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Dec 25, 2012
    @ezio-melotti
    Copy link
    Member Author

    This has already been reported in bpo-11205.

    @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 type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant