[issue45271] Add a 'find' method (a'la str) to list

2021-09-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: This is one bit of symmetry that we shouldn't pursue. The find() methods have been a recurring source of bugs because of failing to check for a -1 result but having that be a valid index into the sequence. Also, the sequence APIs are long established. I

[issue45271] Add a 'find' method (a'la str) to list

2021-09-23 Thread Steve Dower
Steve Dower added the comment: Strings are already special in that str.index() and str.find() both find substrings, while list.index() only finds a single element. If .find() also searched for a substring of the list, I think this could be helpful. Even more so if it used an efficient algori

[issue45271] Add a 'find' method (a'la str) to list

2021-09-23 Thread Dávid Nemeskey
Change by Dávid Nemeskey : -- type: -> enhancement ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue45271] Add a 'find' method (a'la str) to list

2021-09-23 Thread Dávid Nemeskey
New submission from Dávid Nemeskey : There is an unjustified asymmetry between `str` and `list`, as far as lookup goes. Both have an `index()` method that returns the first index of a value, or raises a `ValueError` if it doesn't exist. However, only `str` has the `find` method, which returns