Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-08 Thread Abe Dillon
> > > neither EAFP nor LBYL is "better", they are both appropriate under > different circumstances. Sometimes one is clearer and more efficient than the other. > One of the reasons LBYL is sometimes cleaner than EAPF is because it has more support from the language in the form of an expression

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-06 Thread Steven D'Aprano
On Tue, Nov 06, 2018 at 01:03:54PM -0600, Abe Dillon wrote: > I don't understand the rationale behind PEP 463's rejection. Guido says, "I > disagree with the position that EAFP is better than LBYL, or "generally > recommended" by Python. (Where do you get that?..."; I can't comment on Guido's

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-06 Thread Chris Angelico
On Wed, Nov 7, 2018 at 6:04 AM Abe Dillon wrote: > > Which brings me to the question: What happens when a PEP gets rejected? Is it > final? Is there a process for reviving a PEP? It remains as a permanent document. No, that isn't final; and the process for reviving a PEP basically consists of

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-06 Thread Abe Dillon
I don't understand the rationale behind PEP 463's rejection. Guido says, "I disagree with the position that EAFP is better than LBYL, or "generally recommended" by Python. (Where do you get that?..."; but it's been in the official Python.org docs for a

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Chris Barker via Python-ideas
On Fri, Nov 2, 2018 at 3:59 AM, Steven D'Aprano wrote: > - I'm not volunteering to do the work (I don't know enough C to write > a patch). Unless somebody has a patch, we can't expect the core devs > who aren't interested in this feature to write it. > > (Hence, status quo wins a stalemate.)

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Dan Sommers
On 11/2/18 7:39 AM, Anders Hovmöller wrote:> >> So far, I count 12 people who responded to the original post by >> Giampaolo. By my count, I see: >> >> * five people in favour; >> * three people against, or see no need for it; >> * four people I can't tell if they are for or against, >>

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Anders Hovmöller
> So far, I count 12 people who responded to the original post by > Giampaolo. By my count, I see: > > * five people in favour; > * three people against, or see no need for it; > * four people I can't tell if they are for or against, > (possibly neutral?) [1] For the little it's worth I'm

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Steven D'Aprano
On Fri, Nov 02, 2018 at 10:48:22AM +0200, Serhiy Storchaka wrote: > 31.10.18 21:23, Robert Vanden Eynde пише: > >Should I write a PEP even though I know it's going to be rejected > >because the mailing list was not really into it ? I disagree that "the mailing list was not really into it". So

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Steven D'Aprano
On Thu, Nov 01, 2018 at 09:36:19PM +0200, Serhiy Storchaka wrote: > 31.10.18 13:07, Antoine Pitrou пише: > >l.pop(default=...) has the potential to be multi-thread-safe, while > >your alternatives haven't. > > The multi-thread-safe alternative is: > > try: > value = l.pop() >

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Serhiy Storchaka
31.10.18 21:23, Robert Vanden Eynde пише: Should I write a PEP even though I know it's going to be rejected because the mailing list was not really into it ? It is better to not do this. PEP 572 was initially written with the intention to be rejected.

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread INADA Naoki
On Fri, Nov 2, 2018 at 4:45 AM Serhiy Storchaka wrote: > > 31.10.18 13:08, Antoine Pitrou пише: > > +1 from me. dict.pop() already has an optional default. This is a > > straight-forward improvement to the API and no Python programmer will > > be surprised. > > list.pop() corresponds two dict

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
> > Does it make sense to draw some sort of parallel between next(myiterator, > default="whatever") and mylist.pop(default="whatever")? They exhaust the > iterator/list then start emitting the default argument (if provided). > Yep that's what I just did in my previous mail. """ I think the same

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Nick Timkovich
Does it make sense to draw some sort of parallel between next(myiterator, default="whatever") and mylist.pop(default="whatever")? They exhaust the iterator/list then start emitting the default argument (if provided). On Thu, Nov 1, 2018 at 2:46 PM Serhiy Storchaka wrote: > 31.10.18 13:08,

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
> > There are a number of PEPs in the 8000s that would be worth reading. > Will read that *à l'occaz*, closing the disgression now ^^ ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Chris Angelico
On Fri, Nov 2, 2018 at 11:26 AM Robert Vanden Eynde wrote: >> >> In this case, the governance model for the Python language is being >> discussed. > > > This was the info I was missing, where is it discussed ? Not only on this > list I assume ^^ There are a number of PEPs in the 8000s that

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
> > In this case, the governance model for the Python language is being > discussed. > This was the info I was missing, where is it discussed ? Not only on this list I assume ^^ > Upvotes and downvotes don't mean anything. [...] > Yes, that's why random people wouldn't vote. But like, voting

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Chris Angelico
On Fri, Nov 2, 2018 at 11:19 AM Robert Vanden Eynde wrote: > > Just English Vocabulary, what do you mean by "being in the air at the moment" > ? > Like, that's a subject that a lot of people in here like to talk ? "Up in the air" means uncertain, subject to change.

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Robert Vanden Eynde
Just English Vocabulary, what do you mean by "being in the air at the moment" ? Like, that's a subject that a lot of people in here like to talk ? Yes, to merge or not to merge, but people can UpVote/DownVote can't they ? :D Le ven. 2 nov. 2018 à 01:15, Chris Angelico a écrit : > On Fri, Nov

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Chris Angelico
On Fri, Nov 2, 2018 at 11:12 AM Ethan Furman wrote: > > On 10/31/2018 02:29 PM, Chris Angelico wrote: > > > Exactly how a team of core devs can make unified > > decisions is a little up in the air at the moment > > I wouldn't worry too much about it. I don't think we have ever made > entirely

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Ethan Furman
On 10/31/2018 02:29 PM, Chris Angelico wrote: Exactly how a team of core devs can make unified decisions is a little up in the air at the moment I wouldn't worry too much about it. I don't think we have ever made entirely unified decisions. -- ~Ethan~

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Serhiy Storchaka
31.10.18 13:08, Antoine Pitrou пише: +1 from me. dict.pop() already has an optional default. This is a straight-forward improvement to the API and no Python programmer will be surprised. list.pop() corresponds two dict methods. With argument it corresponds dict.pop(). But there are

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread Serhiy Storchaka
31.10.18 13:07, Antoine Pitrou пише: l.pop(default=...) has the potential to be multi-thread-safe, while your alternatives haven't. The multi-thread-safe alternative is: try: value = l.pop() except IndexError: value = default

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Michael Selik
On Wed, Oct 31, 2018 at 12:31 PM Chris Angelico wrote: > What is being asked for here (if I'm not misreading) is a relatively simple > enhancement to a method on a built-in type (or a small handful of > types). If that garners reasonable support, the next step wouldn't be > a PEP, it'd just go

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Chris Angelico
On Thu, Nov 1, 2018 at 6:25 AM Robert Vanden Eynde wrote: > > Oooh, PEP463, you're reason with I switch to LBYL or write studpid try except > functions so much times. > > Oh and also the local assignement "let/where/statement" :D > > x = (y+1 where y = 3.14) because x = [y+1 for y in [3.14]][0]

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Robert Vanden Eynde
Oooh, PEP463, you're reason with I switch to LBYL or write studpid try except functions so much times. Oh and also the local assignement "let/where/statement" :D x = (y+1 where y = 3.14) because x = [y+1 for y in [3.14]][0] is an overkill and ugly. Should I write a PEP even though I know it's

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Michael Selik
On Wed, Oct 31, 2018 at 10:17 AM Eric Fahlgren wrote: > On Wed, Oct 31, 2018 at 2:42 AM Chris Angelico wrote: > >> https://www.python.org/dev/peps/pep-0463/ wants to say hi. >> > > That was exactly my reaction, too, and usually is whenever one of these > "add a default" or similar ideas pops

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Eric Fahlgren
On Wed, Oct 31, 2018 at 2:42 AM Chris Angelico wrote: > > https://www.python.org/dev/peps/pep-0463/ wants to say hi. > > That was exactly my reaction, too, and usually is whenever one of these "add a default" or similar ideas pops up. 463 should be re-examined, I was very hopeful when it went

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Steven D'Aprano
On Wed, Oct 31, 2018 at 09:31:37PM +1100, Chris Angelico wrote: > > I don't think I would agree with a broad rule "anything that raises can > > return a default value" -- I don't think it makes sense to have, let's > > say, len(obj, default=2). But on a case-by-case basis, it works for me. > >

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Antoine Pitrou
On Wed, 31 Oct 2018 00:44:55 +0100 "Giampaolo Rodola'" wrote: > Sorry in advance if this has been proposed in the past but I couldn't find > anything on python-ideas: > > >>> l = [] > >>> l.pop(default=1) > 1 > > FWIW my use case consists in reading entries from /proc/diskstats where > lines

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Michel Desmoulin
+1 one this. And a list.get method has well, with a default value. Le 31/10/2018 à 00:44, Giampaolo Rodola' a écrit : Sorry in advance if this has been proposed in the past but I couldn't find anything on python-ideas:  >>> l = []  >>> l.pop(default=1) 1 FWIW my use case consists in reading

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Antoine Pitrou
On Wed, 31 Oct 2018 02:25:25 +0200 Serhiy Storchaka wrote: > 31.10.18 01:44, Giampaolo Rodola' пише: > > Sorry in advance if this has been proposed in the past but I couldn't > > find anything on python-ideas: > > > > >>> l = [] > > >>> l.pop(default=1) > > 1 > > > > FWIW my use case

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Chris Angelico
On Wed, Oct 31, 2018 at 9:14 PM Steven D'Aprano wrote: > > On Wed, Oct 31, 2018 at 08:41:28PM +1100, Chris Angelico wrote: > > On Wed, Oct 31, 2018 at 8:24 PM Nicolas Rolin > > wrote: > > > > > > > > > As a user I always found a bit disurbing that dict pop method have a > > > default while

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Steven D'Aprano
On Wed, Oct 31, 2018 at 08:41:28PM +1100, Chris Angelico wrote: > On Wed, Oct 31, 2018 at 8:24 PM Nicolas Rolin wrote: > > > > > > As a user I always found a bit disurbing that dict pop method have a > > default while list and set doesn't. > > While it is way more computationally easy to check

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Chris Angelico
On Wed, Oct 31, 2018 at 8:24 PM Nicolas Rolin wrote: > > > As a user I always found a bit disurbing that dict pop method have a default > while list and set doesn't. > While it is way more computationally easy to check wether a list or a set is > empty that to check if a key is in a dict, it

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Robert Vanden Eynde
I think the same way about set.pop, list.pop. About .index I agree adding default= would make sense but that's not exactly the same thing as the others. Do we have somewhere else a place where a linear search already accepts a default= kwarg ? def index(self, x): for i,y in enumerate(self):

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Ron Reiter
I think l.pop() if l else None is good enough. I think it's pretty obvious that a developer means "Pop the list if the list is not empty, and return None if the list is empty ". - Ron [image: Facebook] [image: Twitter]

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-31 Thread Nicolas Rolin
As a user I always found a bit disurbing that dict pop method have a default while list and set doesn't. While it is way more computationally easy to check wether a list or a set is empty that to check if a key is in a dict, it still create a signature difference for no real reason (having a

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-30 Thread Steven D'Aprano
On Wed, Oct 31, 2018 at 02:25:25AM +0200, Serhiy Storchaka wrote: > 31.10.18 01:44, Giampaolo Rodola' пише: > >Sorry in advance if this has been proposed in the past but I couldn't > >find anything on python-ideas: > > > > >>> l = [] > > >>> l.pop(default=1) > >1 [...] > It is just > >

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-10-30 Thread Serhiy Storchaka
31.10.18 01:44, Giampaolo Rodola' пише: Sorry in advance if this has been proposed in the past but I couldn't find anything on python-ideas: >>> l = [] >>> l.pop(default=1) 1 FWIW my use case consists in reading entries from /proc/diskstats where lines can have a variable number of fields

[Python-ideas] Add "default" kwarg to list.pop()

2018-10-30 Thread Giampaolo Rodola'
Sorry in advance if this has been proposed in the past but I couldn't find anything on python-ideas: >>> l = [] >>> l.pop(default=1) 1 FWIW my use case consists in reading entries from /proc/diskstats where lines can have a variable number of fields depending on the kernel version: