Skip to content

Negative values in positional access inside formatting #77341

Closed

Description

@facundobatista
BPO 33160
Nosy @facundobatista, @ericvsmith
Superseder
  • bpo-7951: Should str.format allow negative indexes when used for getitem access?
  • 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-03-27.21:43:24.292>
    created_at = <Date 2018-03-27.21:07:48.690>
    labels = ['type-feature', '3.8']
    title = 'Negative values in positional access inside formatting'
    updated_at = <Date 2018-03-27.21:43:24.291>
    user = 'https://github.com/facundobatista'

    bugs.python.org fields:

    activity = <Date 2018-03-27.21:43:24.291>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-03-27.21:43:24.292>
    closer = 'serhiy.storchaka'
    components = []
    creation = <Date 2018-03-27.21:07:48.690>
    creator = 'facundobatista'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33160
    keywords = []
    message_count = 1.0
    messages = ['314549']
    nosy_count = 2.0
    nosy_names = ['facundobatista', 'eric.smith']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '7951'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue33160'
    versions = ['Python 3.8']

    Activity

    1. facundobatista commented on Mar 27, 2018

      @facundobatista
      MemberAuthor

      This works fine:

      >>> "{[0]}".format([1, 2, 3])
      '1'

      This should work too:

      >>> "{[-1]}".format([1, 2, 3])
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: list indices must be integers or slices, not str
    2. 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.8 (EOL)end of lifetype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions