[Python-ideas] Python Enhancement Proposal for List methods
storchaka at gmail.com
Sun Oct 21 10:51:18 EDT 2018
21.10.18 16:00, Siva Sukumar Reddy пише:
> I am really new to Python contribution community want to propose below
> methods for List object. Forgive me if this is not the format to send an
> 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all
> the occurrences of an element in the list instead of writing a new list
> comprehension in place.
> 2. *list.replace( item_to_be_replaced, new_item, number_of_occurrences
> )*: which replaces the occurrences of an element in the list till
> specific number of occurrences of that element. The
> number_of_occurrences can defaulted to 0 which will replace all the
> occurrences in place.
> 3. *list.removeall( item_to_be_removed )*: which removes all the
> occurrences of an element in a list in place.
> What do you think about these features?
> Are they PEP-able? Did anyone tried to implement these features before?
> Please let me know.
See the previous discussion about this three years ago:
The conclusion is that this feature is too niche. It works only with
lists, and supports only one test predicate (equality to a specified
value). filter() and comprehensions are more general.
More information about the Python-ideas