Skip to content

The error message of list.remove() says x instead of value and list.remove(x): isn't necessary: #137508

@hyperkai

Description

@hyperkai

The docstring of list.remove() says value parameter as shown below:

print(help(list.remove))
# remove(self, value, /) unbound builtins.list method
#     Remove first occurrence of value.
#
#     Raises ValueError if the value is not present.

But the error message says x instead of value as shown below and I don't think list.remove(x): is necessary:

v = ['a', 'b', 'c']

v.remove('B')
# ValueError: list.remove(x): x not in list

So, the error message should just say as shown below:

ValueError: value not in list

In addition, the docstring of bytearray.remove() says valueparameter as shown below:

print(help(bytearray.remove))
# remove(self, value, /) unbound builtins.bytearray method
#     Remove the first occurrence of a value in the bytearray.
#
#     value
#       The value to remove.

And, the error message reasonably says value as shown below but I don't think found is necessary:

v = bytearray(b'abc')

v.remove(ord('B'))
# ValueError: value not found in bytearray

So, the error message should just say as shown below:

ValueError: value not in bytearray

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is provided

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions