Message402502
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 algorithm (bearing in mind that the arbitrary comparisons between elements - something else that doesn't exist in strings - would make this complicated).
This is probably something to bring up on the python-ideas mailing list first, anyway. Symmetry is not a sufficient reason in itself to add new APIs - often the asymmetry exists because the "missing" one is only there for legacy/compatibility reasons, not because it is a good API. |
|
Date |
User |
Action |
Args |
2021-09-23 15:55:31 | steve.dower | set | recipients:
+ steve.dower, nemeskeyd |
2021-09-23 15:55:31 | steve.dower | set | messageid: <1632412531.48.0.826578916656.issue45271@roundup.psfhosted.org> |
2021-09-23 15:55:31 | steve.dower | link | issue45271 messages |
2021-09-23 15:55:31 | steve.dower | create | |
|