[Python-ideas] Python Enhancement Proposal for List methods

Siva Sukumar Reddy sukurcf at gmail.com
Mon Oct 22 02:23:20 EDT 2018


Sounds good to me. Thanks.

On Mon 22 Oct, 2018, 06:18 David Mertz, <mertz at gnosis.cx> wrote:

> I have changed my opinion to -1 on list.replace(). While max=n is a useful
> argument, a plain function could work equally well on every sequence and
> not be specific to lists.
>
> On Sun, Oct 21, 2018, 10:18 AM David Mertz <mertz at gnosis.cx wrote:
>
>> The list comprehensions are not very hard, and are more general. EXCEPT
>> with the limited number of occurrences. We have this for str.replace(...,
>> max=n), and it is useful fairly often.
>>
>> I'm +0.5 on .replace() with that capability. But -1 on .removeall() that
>> adds nothing to an easy listcomp.
>>
>> On Sun, Oct 21, 2018, 9:01 AM Siva Sukumar Reddy <sukurcf at gmail.com
>> wrote:
>>
>>> Hey everyone,
>>>
>>> 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
>>> email.
>>>
>>> 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.
>>>
>>> Thank you,
>>> Sukumar
>>> _______________________________________________
>>> Python-ideas mailing list
>>> Python-ideas at python.org
>>> https://mail.python.org/mailman/listinfo/python-ideas
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181022/dce043c5/attachment.html>


More information about the Python-ideas mailing list