<div dir="auto"><div>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.</div><div dir="auto"><br></div><div dir="auto">I'm +0.5 on .replace() with that capability. But -1 on .removeall() that adds nothing to an easy listcomp.<br><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Sun, Oct 21, 2018, 9:01 AM Siva Sukumar Reddy <<a href="mailto:sukurcf@gmail.com">sukurcf@gmail.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hey everyone,</div><div><br></div><div>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.<br></div><div><br></div><div>1. <b>list.replace( item_to_be_replaced, new_item )</b>: which replaces all the occurrences of an element in the list instead of writing a new list comprehension in place.</div><div>2. <b>list.replace( item_to_be_replaced, new_item, number_of_occurrences )</b>:
 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.</div><div>3. <b>list.removeall( item_to_be_removed )</b>: which removes all the occurrences of an element in a list in place.</div><div><br></div><div>What do you think about these features?</div><div>Are they PEP-able? Did anyone tried to implement these features before?<br></div><div>Please let me know.</div><div><br></div><div>Thank you,</div><div>Sukumar</div></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div></div>