Skip to content

tuple.index() could return a more explicit error message #77741

Closed

Description

@CyrilRoelandteNovance
BPO 33560
Nosy @serhiy-storchaka, @CyrilRoelandteNovance
PRs
  • bpo-33560: improve the error message returned by tuple.index #6944
  • Superseder
  • bpo-13349: Non-informative error message in index() and remove() functions
  • 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-05-17.16:47:25.763>
    created_at = <Date 2018-05-17.16:20:20.263>
    labels = ['type-feature', '3.8']
    title = 'tuple.index() could return a more explicit error message'
    updated_at = <Date 2018-05-17.16:47:25.761>
    user = 'https://github.com/CyrilRoelandteNovance'

    bugs.python.org fields:

    activity = <Date 2018-05-17.16:47:25.761>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-05-17.16:47:25.763>
    closer = 'serhiy.storchaka'
    components = []
    creation = <Date 2018-05-17.16:20:20.263>
    creator = 'Cyril Roelandt'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33560
    keywords = ['patch']
    message_count = 2.0
    messages = ['316955', '316964']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'Cyril Roelandt']
    pr_nums = ['6944']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '13349'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue33560'
    versions = ['Python 3.8']

    Activity

    1. CyrilRoelandteNovance commented on May 17, 2018

      CyrilRoelandteNovancemannequin
      MannequinAuthor

      The tuple.index() method returns an error message that does not allow users to know what element was being looked for inside the tuple:

      >>> ().index(1)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ValueError: tuple.index(x): x not in tuple

      The list.index() method has a much better error message:

      >>> [].index(1)   
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ValueError: 1 is not in list

      We could improve tuple.index() so that its behaviour becomes similar to that of list.index().

    2. added
      3.8 (EOL)
      type-feature
      on May 17, 2018
    3. serhiy-storchaka commented on May 17, 2018

      @serhiy-storchaka
      Member

      This is a duplicate of bpo-13349.

    4. 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)type-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions