Content-Length: 286702 | pFad | https://github.com/python/cpython/issues/96844

06 Show value in error of list.remove · Issue #96844 · python/cpython · GitHub
Skip to content

Show value in error of list.remove #96844

@tdegeus

Description

@tdegeus

Consider

foo = ["a", "b"]
for i in ["c"]:
    foo.remove(i)

This throws with a useless error message:

Traceback (most recent call last):
  File "/Users/tdegeus/Downloads/t.py", line 3, in <module>
    foo.remove(i)
ValueError: list.remove(x): x not in list

Instead it would be very helpful to show the value of x. Now one needs extra manual debugging, or extra lines of code.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/96844

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy