Re: [Python-ideas] Python Enhancement Proposal for List methods

2018-10-22 Thread Siva Sukumar Reddy
Sounds good to me. Thanks. On Mon 22 Oct, 2018, 06:18 David Mertz, 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

Re: [Python-ideas] Python Enhancement Proposal for List methods

2018-10-21 Thread David Mertz
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 The list comprehensions are not very hard, and are more general. EXCEPT > with

Re: [Python-ideas] Python Enhancement Proposal for List methods

2018-10-21 Thread Chris Angelico
On Mon, Oct 22, 2018 at 7:58 AM Terry Reedy wrote: > > An indefinite number of in-place removes is a generally a bad idea > unless done carefully. > alist.remove is inherently O(n). > alist.removeall implemented naively would be O(n*n)/ > alist = [x for x in alist if x == old] or > alist = list(x

Re: [Python-ideas] Python Enhancement Proposal for List methods

2018-10-21 Thread Terry Reedy
On 10/21/2018 9:00 AM, Siva Sukumar Reddy wrote: I am really new to Python contribution community want to propose below methods for List object. For most classes, there is an infinite number of possible functions that could be made into methods. The Python philosophy is to include as

Re: [Python-ideas] Python Enhancement Proposal for List methods

2018-10-21 Thread Serhiy Storchaka
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 email. 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all the occurrences of an element

Re: [Python-ideas] Python Enhancement Proposal for List methods

2018-10-21 Thread David Mertz
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

[Python-ideas] Python Enhancement Proposal for List methods

2018-10-21 Thread Siva Sukumar Reddy
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