Re: [Python-ideas] An exciting opportunity to update PEP 3156

2016-09-11 Thread Andrew Svetlov
Should Task.current_task() be declared as a part of supported public API? Should we declare that every asyncio coroutine is executed in a task context? On Mon, Sep 12, 2016 at 4:53 AM Yury Selivanov wrote: > Guido and I are looking for help with PEP 3156. Currently it's out of > sync with the d

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread Nick Coghlan
On 11 September 2016 at 19:36, Dominik Gresch wrote: > Hi, > > I've recently found myself writing code similar to this: > > for i in range(10): > if i == 5: > continue > "body" > > which I find a bit ugly. Obviously the same could be written as > > for i in range(10): > if i !=

[Python-ideas] An exciting opportunity to update PEP 3156

2016-09-11 Thread Yury Selivanov
Guido and I are looking for help with PEP 3156. Currently it's out of sync with the docs. It would be cool if someone could volunteer and update it (at least make sure that all APIs are up to date). Yury ___ Python-ideas mailing list Python-ideas@pyt

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-11 Thread David Mertz
On Sun, Sep 11, 2016 at 6:11 PM, Guido van Rossum wrote: > On Sun, Sep 11, 2016 at 6:00 PM, David Mertz wrote: > > None if a is None else a.foo > > This is the crux of the matter to me. It's just too verbose, and the > `if` and `else` keywords are lost in the noise of all the other words > o

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-11 Thread Guido van Rossum
On Sun, Sep 11, 2016 at 6:00 PM, David Mertz wrote: > None if a is None else a.foo This is the crux of the matter to me. It's just too verbose, and the `if` and `else` keywords are lost in the noise of all the other words on the line. Plus the big win when it applies) is that if `a` is in fac

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-11 Thread MRAB
On 2016-09-12 01:26, Guido van Rossum wrote: On Sun, Sep 11, 2016 at 12:44 PM, Daniel Moisset wrote: Both this discussion, PEP 505, and the one a year ago, tend to mix up 2 related but separate proposals: I don't think there's that much of a mix-up. PEP 505 clearly describes each proposal sep

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-11 Thread David Mertz
On Sun, Sep 11, 2016 at 12:44 PM, Daniel Moisset wrote: > Both this discussion, PEP 505, and the one a year ago, tend to mix up 2 > related but separate proposals: > w > (A) Add a None-coalescing operator (like C# a ?? b, what you would write > in Python as "a or b" if it didn't have the falsy go

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-11 Thread Guido van Rossum
On Sun, Sep 11, 2016 at 12:44 PM, Daniel Moisset wrote: > Both this discussion, PEP 505, and the one a year ago, tend to mix up 2 > related but separate proposals: I don't think there's that much of a mix-up. PEP 505 clearly describes each proposal separately and even gives a choice to accept or

Re: [Python-ideas] [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-11 Thread Tim Peters
[redirected from python-dev, to python-ideas; please send followups only to python-ideas] [Elliot Gorokhovsky ] > ... > TL;DR: Should I spend time making list.sort() detect if it is sorting > lexicographically and, if so, use a much faster algorithm? It will be fun to find out ;-) As Mark, and

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread Sven R. Kunze
On 11.09.2016 22:15, C Anthony Risinger wrote: On Sep 11, 2016 7:11 AM, "Chris Angelico" > wrote: > > That said, though, filtered iteration isn't common enough to demand > its own syntax IMO. I do it fairly often, I do it often enough to want this. Same here. Most

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread C Anthony Risinger
On Sep 11, 2016 7:11 AM, "Chris Angelico" wrote: > > That said, though, filtered iteration isn't common enough to demand > its own syntax IMO. I do it fairly often, I do it often enough to want this. When I first started writing Python this struck me as an inconsistency... if it's useful in compr

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-11 Thread Daniel Moisset
Both this discussion, PEP 505, and the one a year ago, tend to mix up 2 related but separate proposals: w (A) Add a None-coalescing operator (like C# a ?? b, what you would write in Python as "a or b" if it didn't have the falsy gotcha) (B) Add some None-aware navigation operators ( The "?.", "?()"

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread Chris Angelico
On Sun, Sep 11, 2016 at 9:59 PM, Paul Moore wrote: > # Hacky use of a generator expression: > for i in (x for x in range(10) if x != 5): > body() This is what I'd like to compare the proposal against. It's perfectly legal but pretty ugly - why should you nest two 'for' loops just for the sake

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread Paul Moore
On 11 September 2016 at 10:36, Dominik Gresch wrote: > I've recently found myself writing code similar to this: > > for i in range(10): > if i == 5: > continue > "body" > > which I find a bit ugly. I write code like this quite frequently. However, unlike you I don't find it partic

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread אלעזר
This has come up before. It will be a special case of making "if" without "else" result in a special "empty" type that is not part of the iteration. As in `[1, (2 if False) ] == [1]`. בתאריך יום א׳, 11 בספט' 2016, 13:29, מאת Bernardo Sulzbach ‏< mafagafogiga...@gmail.com>: > On 09/11/2016 06:36 A

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread Bernardo Sulzbach
On 09/11/2016 06:36 AM, Dominik Gresch wrote: So I asked myself if a syntax as follows would be possible: for i in range(10) if i != 5: body Personally, I find this extremely intuitive since this kind of if-statement is already present in list comprehensions. What is your opinion on this?

[Python-ideas] if-statement in for-loop

2016-09-11 Thread Dominik Gresch
Hi, I've recently found myself writing code similar to this: for i in range(10): if i == 5: continue "body" which I find a bit ugly. Obviously the same could be written as for i in range(10): if i != 5: "body" but here you would have to look at the end of the body