Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-29 Thread Nick Coghlan
On 28 March 2018 at 00:52, Ethan Furman wrote: > On 03/25/2018 09:46 AM, Ethan Furman wrote: >> >> On 03/24/2018 09:24 PM, Nick Coghlan wrote: >> >>> No, the fact that the expression defining the outermost iterable gets >>> evaluated in the outer scope is behaviour that's >>>

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-27 Thread Ethan Furman
On 03/25/2018 09:46 AM, Ethan Furman wrote: On 03/24/2018 09:24 PM, Nick Coghlan wrote: No, the fact that the expression defining the outermost iterable gets evaluated in the outer scope is behaviour that's explicitly tested for in the regression test suite. The language reference spells out

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-26 Thread Christoph Groth
Nick Coghlan wrote: > On 25 March 2018 at 22:44, Christoph Groth wrote: > > I think that it's a helpful guideline to imagine what the ideal > > behavior should be if we were not constrained by backwards > > compatibility, and then try to follow it. In the case at hand,

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-25 Thread Ethan Furman
On 03/24/2018 09:24 PM, Nick Coghlan wrote: No, the fact that the expression defining the outermost iterable gets evaluated in the outer scope is behaviour that's explicitly tested for in the regression test suite. The language reference spells out that this is intentional for generator

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-25 Thread Nick Coghlan
On 25 March 2018 at 22:44, Christoph Groth wrote: > I think that it's a helpful guideline to imagine what the ideal behavior > should be if we were not constrained by backwards compatibility, and > then try to follow it. In the case at hand, we all seem to agree that >

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-25 Thread Christoph Groth
Chris Angelico wrote: > On Sun, Mar 25, 2018 at 8:31 PM, Christoph Groth > wrote: > > That's indeed a bit strange, and I would consider it somewhat of a wart > > of the language. But as far as I can tell remaining compatible with the > > above behavior does not force us

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-25 Thread Chris Angelico
On Sun, Mar 25, 2018 at 8:31 PM, Christoph Groth wrote: > That's indeed a bit strange, and I would consider it somewhat of a wart > of the language. But as far as I can tell remaining compatible with the > above behavior does not force us to leak assignments from the

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-25 Thread Christoph Groth
Nick Coghlan wrote: > It would also result in two different ways to handle traditional > assignments: > > x = expr > x := expr > > Perhaps ":=" could be explicitly restricted to only single names on > the LHS, without any of the clever unpacking features of full > assignment statements?

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-25 Thread Christoph Groth
Nick Coghlan wrote: > On 24 March 2018 at 23:29, Christoph Groth wrote: > > x = [n * m for n in range(4) for m in range(5)] > > > > be equally well equivalent to > > > > def (): > > ret = [] > > for n in range(4): > > for m in range(5): > >

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Guido van Rossum
On Sat, Mar 24, 2018 at 7:08 PM, Nick Coghlan wrote: > On 25 March 2018 at 02:34, Eric Fahlgren wrote: > >> On Sat, Mar 24, 2018 at 7:14 AM, Nick Coghlan wrote: >> >>> ​​ >>> >>> class C: >>> ... sequence = range(10)

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Nick Coghlan
On 25 March 2018 at 14:08, Ethan Furman wrote: > Looks like a buggy implementation detail. Any assignments that happen > inside a listcomp should be effective only inside the listcomp. > No, the fact that the expression defining the outermost iterable gets evaluated in the

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Chris Angelico
On Sun, Mar 25, 2018 at 3:08 PM, Ethan Furman wrote: > On 03/24/2018 09:00 PM, Chris Angelico wrote: >> >> On Sun, Mar 25, 2018 at 2:59 PM, Ethan Furman wrote: >>> >>> On 03/24/2018 08:51 PM, Chris Angelico wrote: > > Let's suppose we have assignment expressions. I'm

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Nick Coghlan
On 25 March 2018 at 13:51, Chris Angelico wrote: > On Sun, Mar 25, 2018 at 2:48 PM, Ethan Furman wrote: > > On 03/24/2018 01:35 AM, Nick Coghlan wrote: > > > >> In comprehensions and generator expressions, we'd need to explain why > >> inline assignments in

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Ethan Furman
On 03/24/2018 09:00 PM, Chris Angelico wrote: On Sun, Mar 25, 2018 at 2:59 PM, Ethan Furman wrote: On 03/24/2018 08:51 PM, Chris Angelico wrote: Let's suppose we have assignment expressions. I'm going to use "(expr as name)" syntax for this example. a = [(1 as b) for c in (d as e) if (2 as

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Chris Angelico
On Sun, Mar 25, 2018 at 2:59 PM, Ethan Furman wrote: > On 03/24/2018 08:51 PM, Chris Angelico wrote: >> >> On Sun, Mar 25, 2018 at 2:48 PM, Ethan Furman wrote: >>> >>> On 03/24/2018 01:35 AM, Nick Coghlan wrote: >>> In comprehensions and generator expressions, we'd need

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Ethan Furman
On 03/24/2018 08:51 PM, Chris Angelico wrote: On Sun, Mar 25, 2018 at 2:48 PM, Ethan Furman wrote: On 03/24/2018 01:35 AM, Nick Coghlan wrote: In comprehensions and generator expressions, we'd need to explain why inline assignments in the outermost iterator expression leak but those in filter

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Chris Angelico
On Sun, Mar 25, 2018 at 2:48 PM, Ethan Furman wrote: > On 03/24/2018 01:35 AM, Nick Coghlan wrote: > >> In comprehensions and generator expressions, we'd need to explain why >> inline assignments in the outermost iterator >> expression leak but those in filter expressions,

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Ethan Furman
On 03/24/2018 01:35 AM, Nick Coghlan wrote: In comprehensions and generator expressions, we'd need to explain why inline assignments in the outermost iterator expression leak but those in filter expressions, inner iterator expressions, and result expressions don't. I don't understand --

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Nick Coghlan
On 25 March 2018 at 01:03, Kirill Balunov wrote: > > > 2018-03-24 17:14 GMT+03:00 Nick Coghlan : >> >> >> They can be distinguished, just not at module or function scope. To give >> a concrete example: >> >> == >> >>> class C: >> ...

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Nick Coghlan
On 25 March 2018 at 02:34, Eric Fahlgren wrote: > On Sat, Mar 24, 2018 at 7:14 AM, Nick Coghlan wrote: > >> ​​ >> >>> class C: >> ... sequence = range(10) >> ... listcomp = [x for x in sequence] >> > > >>> class C: > ... y = 1

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Eric Fahlgren
On Sat, Mar 24, 2018 at 7:14 AM, Nick Coghlan wrote: > ​​ > >>> class C: > ... sequence = range(10) > ... listcomp = [x for x in sequence] > >>> class C: ... y = 1 ... sequence = range(10) ... listcomp = [x+y for x in sequence] ​ ...

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Kirill Balunov
2018-03-24 17:14 GMT+03:00 Nick Coghlan : > > > They can be distinguished, just not at module or function scope. To give a > concrete example: > > == > >>> class C: > ... sequence = range(10) > ... listcomp = [x for x in sequence] > ... def

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Nick Coghlan
On 24 March 2018 at 23:29, Christoph Groth wrote: > > x = [n * m for n in range(4) for m in range(5)] > > be equally well equivalent to > > def (): > ret = [] > for n in range(4): > for m in range(5): > ret.append(n * m) > return ret > x

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Nick Coghlan
On 24 March 2018 at 21:49, Paul Moore wrote: > On 24 March 2018 at 09:18, Chris Angelico wrote: > > So the first (outermost) iterable is actually evaluated in the > > caller's scope, but everything else is inside a subscope. Thus an > > assignment inside

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Christoph Groth
Chris Angelico wrote: > On Sat, Mar 24, 2018 at 8:07 PM, Christoph Groth > wrote: > > Chris Angelico wrote: > > > >> Thank you; both of these have now been incorporated into the document. > > > > Thanks! Just a small comment. You wrote in the PEP draft: > > > >> # Name

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Paul Moore
On 24 March 2018 at 12:18, Chris Angelico wrote: > On Sat, Mar 24, 2018 at 11:06 PM, Paul Moore wrote: >> On 24 March 2018 at 11:55, Chris Angelico wrote: >>> On Sat, Mar 24, 2018 at 10:49 PM, Paul Moore wrote:

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Chris Angelico
On Sat, Mar 24, 2018 at 11:06 PM, Paul Moore wrote: > On 24 March 2018 at 11:55, Chris Angelico wrote: >> On Sat, Mar 24, 2018 at 10:49 PM, Paul Moore wrote: >>> On 24 March 2018 at 09:18, Chris Angelico wrote:

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Paul Moore
On 24 March 2018 at 11:55, Chris Angelico wrote: > On Sat, Mar 24, 2018 at 10:49 PM, Paul Moore wrote: >> On 24 March 2018 at 09:18, Chris Angelico wrote: >>> Except that a list comprehension is implemented using an inner >>> function.

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Chris Angelico
On Sat, Mar 24, 2018 at 10:49 PM, Paul Moore wrote: > On 24 March 2018 at 09:18, Chris Angelico wrote: >> Except that a list comprehension is implemented using an inner >> function. Very approximately: >> >> x = [n * m for n in range(4) for m in range(5)]

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Paul Moore
On 24 March 2018 at 09:18, Chris Angelico wrote: > On Sat, Mar 24, 2018 at 8:07 PM, Christoph Groth > wrote: >> Chris Angelico wrote: >> >>> Thank you; both of these have now been incorporated into the document. >> >> Thanks! Just a small comment.

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Christoph Groth
Chris Angelico wrote: > Thank you; both of these have now been incorporated into the document. Thanks! Just a small comment. You wrote in the PEP draft: > # Name bindings inside list comprehensions usually won't leak > ... > # But occasionally they will! I don't understand what you mean

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Chris Angelico
On Sat, Mar 24, 2018 at 3:16 PM, Masayuki YAMAMOTO wrote: > FWIW, I thought another way which provides cache object library, it seems to > just work in some cases. But it doesn't create statement local scope and > might be difficult to read because looks ordinary

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Chris Angelico
On Sat, Mar 24, 2018 at 8:07 PM, Christoph Groth wrote: > Chris Angelico wrote: > >> Thank you; both of these have now been incorporated into the document. > > Thanks! Just a small comment. You wrote in the PEP draft: > >> # Name bindings inside list comprehensions

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-24 Thread Nick Coghlan
On 24 March 2018 at 13:15, Chris Angelico wrote: > On Sat, Mar 24, 2018 at 2:09 PM, Ethan Furman wrote: > > I'm certainly hoping PEP 572 is rejected so we can have a follow-up PEP > that > > only deals with the assignment-as-expression portion. > > > > No

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-23 Thread Masayuki YAMAMOTO
FWIW, I thought another way which provides cache object library, it seems to just work in some cases. But it doesn't create statement local scope and might be difficult to read because looks ordinary expression doing magic. Chris, would you append the library to alternative proposal section?

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-23 Thread Chris Angelico
On Sat, Mar 24, 2018 at 2:09 PM, Ethan Furman wrote: > On 03/23/2018 07:38 PM, Chris Angelico wrote: >> >> On Sat, Mar 24, 2018 at 3:58 AM, Guido van Rossum wrote: >>> >>> On Fri, Mar 23, 2018 at 9:34 AM, Christoph Groth wrote: > > But wouldn't it be a good alternative to

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-23 Thread Ethan Furman
On 03/23/2018 07:38 PM, Chris Angelico wrote: On Sat, Mar 24, 2018 at 3:58 AM, Guido van Rossum wrote: On Fri, Mar 23, 2018 at 9:34 AM, Christoph Groth wrote: But wouldn't it be a good alternative to PEP 572 to *add* an assignment operator that is an expression to Python, and is distinct

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-23 Thread Chris Angelico
On Sat, Mar 24, 2018 at 3:58 AM, Guido van Rossum wrote: > I also think it's fair to at least reconsider adding inline assignment, with > the "traditional" semantics (possibly with mandatory parentheses). This > would be easier to learn and understand for people who are familiar

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-23 Thread Guido van Rossum
I also think it's fair to at least reconsider adding inline assignment, with the "traditional" semantics (possibly with mandatory parentheses). This would be easier to learn and understand for people who are familiar with it from other languages (C++, Java, JavaScript). On Fri, Mar 23, 2018 at

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-17 Thread David Foster
I mean approximately local to one line of source code. Perhaps the unpopular opinion based on your reaction. :) More specifically, for a simple statement (with no trailing colon), there is one scope enclosing everything in the statement. For a compound statement, composed of multiple clauses,

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-17 Thread Chris Angelico
On Sat, Mar 17, 2018 at 5:49 PM, David Foster wrote: > (3a) With a header-limited scope (in proposal #1 above), I advocate that a > named expression should NOT be able to shadow other variables, giving a > SyntaxError. I can't think of a reasonable reason why such shadowing

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-17 Thread David Foster
(1) I am concerned with the proposal's ability to introduce variables with a new broader kind of multi-line scope not seen anywhere else in Python. It is difficult to reason about, particularly in constructs like lambdas and inline def functions. Limiting scope to the very same line is great: >

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-06 Thread Rhodri James
On 02/03/18 20:02, Jonathan Goble wrote: On Fri, Mar 2, 2018 at 2:56 PM Robert Vanden Eynde wrote: @Rhodri, this is what Everybody does because you hit the "reply to all" button, but, we don't receive two copies on the mail, I don't know why (but that's a good thing).

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-04 Thread Stephen J. Turnbull
Chris Angelico writes: > > So what happens to rejected alternatives when the PEP itself is rejected? > > ;) > > > > Algebraically, they must be accepted. Right? That's not how de Moivre's laws work. ;-) ___ Python-ideas mailing list

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-03 Thread Chris Angelico
On Sat, Mar 3, 2018 at 7:23 PM, Ethan Furman wrote: > On 03/02/2018 07:30 PM, Chris Angelico wrote: >> >> On Sat, Mar 3, 2018 at 12:48 PM, Greg Ewing wrote: >>> >>> Chris Angelico wrote: It would NOT work for anything where the bool() of the desired object

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-03 Thread Ethan Furman
On 03/02/2018 07:30 PM, Chris Angelico wrote: On Sat, Mar 3, 2018 at 12:48 PM, Greg Ewing wrote: Chris Angelico wrote: It would NOT work for anything where the bool() of the desired object doesn't exactly match the loop's condition. while condition(x) where x = something(): ...

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 12:48 PM, Greg Ewing wrote: > Chris Angelico wrote: >> >> It would NOT work for anything where the bool() of >> the desired object doesn't exactly match the loop's condition. > > >while condition(x) where x = something(): > ... > And

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Greg Ewing
Chris Angelico wrote: It would NOT work for anything where the bool() of the desired object doesn't exactly match the loop's condition. while condition(x) where x = something(): ... -- Greg ___ Python-ideas mailing list

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Robert Vanden Eynde
Le 2 mars 2018 22:21, "Robert Vanden Eynde" a écrit : Le 2 mars 2018 22:13, "Chris Angelico" a écrit : On Sat, Mar 3, 2018 at 7:47 AM, Robert Vanden Eynde wrote: >> And please, don't top-post. Again, if your mail client encourages

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Eric Fahlgren
On Fri, Mar 2, 2018 at 12:20 PM, Chris Angelico wrote: > How often do you have a loop like this where you actually want to > capture the exact condition? I can think of two: regular expressions > (match object or None), and socket read (returns empty string on EOF). > This

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Robert Vanden Eynde
Le 2 mars 2018 22:13, "Chris Angelico" a écrit : On Sat, Mar 3, 2018 at 7:47 AM, Robert Vanden Eynde wrote: >> And please, don't top-post. Again, if your mail client encourages top >> posting, either override it, or get a better one. > > @Chris @Rohdri

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 7:47 AM, Robert Vanden Eynde wrote: >> And please, don't top-post. Again, if your mail client encourages top >> posting, either override it, or get a better one. > > @Chris @Rohdri (@Jonathan below) > > For morons like me who didn't know what

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Robert Vanden Eynde
Le 2 mars 2018 22:03, "Ethan Furman" a écrit : On 03/02/2018 12:47 PM, Robert Vanden Eynde wrote: @Chris @Rohdri (@Jonathan below) > > For morons like me who didn't know what "top-posting" was, I went on > Wikipedia > (https://en.m.wikipedia.org/wiki/Posting_style < >

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 7:31 AM, Brendan Barnwell wrote: > On 2018-03-02 12:20, Chris Angelico wrote: >> >> On Sat, Mar 3, 2018 at 7:04 AM, Eric Fahlgren >> wrote: >>> >>> >>> On Fri, Mar 2, 2018 at 10:27 AM, Jelle Zijlstra >>>

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Ethan Furman
On 03/02/2018 12:47 PM, Robert Vanden Eynde wrote: @Chris @Rohdri (@Jonathan below) For morons like me who didn't know what "top-posting" was, I went on Wikipedia (https://en.m.wikipedia.org/wiki/Posting_style ). You looked it up and researched

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Robert Vanden Eynde
Le 2 mars 2018 21:02, "Chris Angelico" a écrit : On Sat, Mar 3, 2018 at 6:55 AM, Robert Vanden Eynde wrote: > @Rhodri, this is what Everybody does because you hit the "reply to all" > button, but, we don't receive two copies on the mail, I don't know why

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Brendan Barnwell
On 2018-03-02 12:20, Chris Angelico wrote: On Sat, Mar 3, 2018 at 7:04 AM, Eric Fahlgren wrote: On Fri, Mar 2, 2018 at 10:27 AM, Jelle Zijlstra wrote: I wonder if we could have a more limited change to the language that would allow only

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 7:04 AM, Eric Fahlgren wrote: > > On Fri, Mar 2, 2018 at 10:27 AM, Jelle Zijlstra > wrote: >> >> >> I wonder if we could have a more limited change to the language that would >> allow only the as/while use cases.

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Eric Fahlgren
On Fri, Mar 2, 2018 at 10:27 AM, Jelle Zijlstra wrote: > > I wonder if we could have a more limited change to the language that would > allow only the as/while use cases. Specifically, that means we could do: > > while do_something() as x: > print(x) > ​The "while"

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Jonathan Goble
On Fri, Mar 2, 2018 at 2:56 PM Robert Vanden Eynde wrote: > @Rhodri, this is what Everybody does because you hit the "reply to all" > button, but, we don't receive two copies on the mail, I don't know why (but > that's a good thing). > > Le 2 mars 2018 20:48, "Rhodri James"

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 6:55 AM, Robert Vanden Eynde wrote: > @Rhodri, this is what Everybody does because you hit the "reply to all" > button, but, we don't receive two copies on the mail, I don't know why (but > that's a good thing). > > Le 2 mars 2018 20:48, "Rhodri James"

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Robert Vanden Eynde
@Rhodri, this is what Everybody does because you hit the "reply to all" button, but, we don't receive two copies on the mail, I don't know why (but that's a good thing). Le 2 mars 2018 20:48, "Rhodri James" a écrit : On 02/03/18 18:27, Jelle Zijlstra wrote: > 2018-03-02

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Rhodri James
On 02/03/18 18:27, Jelle Zijlstra wrote: 2018-03-02 7:03 GMT-08:00 Robert Vanden Eynde : Guys, please don't email to me *and* the mailing list. Getting two copies of your deathless prose makes me less likely to pay attention to you, not more. -- Rhodri James *-*

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread David Mertz
On Fri, Mar 2, 2018 at 10:44 AM, Ethan Furman wrote: > On 03/02/2018 09:34 AM, David Mertz wrote: > >> >>> with bind(sqrt(2), log(2)) as (a, b): >> ... print(a, b, a+b) >> 1.4142135623730951 0.6931471805599453 2.1073607429330403 >> >> This would cover 98% of

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 5:30 AM, Brendan Barnwell wrote: > But if that's the case, maybe what we want is actually another thing > that's been discussed many times on this list, namely something like a > with-block that can define "super-local" variables that

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Ethan Furman
On 03/02/2018 09:34 AM, David Mertz wrote: So right now, I can do these: class bind(object): def __init__(self, *args): self.args = args def __enter__(self): return self.args[0] if len(self.args)==1 else self.args def __exit__(self,

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Ethan Furman
On 03/02/2018 08:04 AM, Chris Angelico wrote: On Sat, Mar 3, 2018 at 1:53 AM, Rhodri James wrote: On 02/03/18 11:43, Chris Angelico wrote: # Compound statements usually enclose everything... if (re.match(...) as m): print(m.groups(0)) print(m) # NameError This

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 5:27 AM, Jelle Zijlstra wrote: > > > 2018-03-02 7:03 GMT-08:00 Robert Vanden Eynde : >> >> +1 on extracting the big win for "if" and "while" (the regex case is >> wonderul). It would be see as an "extended if/while" rather

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Brendan Barnwell
On 2018-03-02 03:43, Chris Angelico wrote: After dozens of posts and a wide variety of useful opinions and concerns being raised, here is the newest version of PEP 572 for your debating pleasure. After following the discussion here, I think I've come to the conclusion that something like

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Jelle Zijlstra
2018-03-02 7:03 GMT-08:00 Robert Vanden Eynde : > +1 on extracting the big win for "if" and "while" (the regex case is > wonderul). It would be see as an "extended if/while" rather than a general > statement assignation. > > I wonder if we could have a more limited change to

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Ethan Furman
On 03/02/2018 03:43 AM, Chris Angelico wrote: PEP: 572 Title: Syntax for Statement-Local Name Bindings Author: Chris Angelico Looks nice, thanks for the updates! Alternative proposals = 6. Allowing ``(EXPR as NAME)`` to assign to any form of name.

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread David Mertz
I remain -1 on the PEP, but thank you very much Chris for the great work writing it and the extra clarifications in it. The part I like most about the proposal is the use in blocks, like: if (re.match(...) as m): print(m.groups(0)) if (input("> ") as cmd): def run_cmd(cmd=cmd): #

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Sat, Mar 3, 2018 at 1:53 AM, Rhodri James wrote: > On 02/03/18 11:43, Chris Angelico wrote: >> >> After dozens of posts and a wide variety of useful opinions and >> concerns being raised, here is the newest version of PEP 572 for your >> debating pleasure. > > > I haven't

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Robert Vanden Eynde
+1 on extracting the big win for "if" and "while" (the regex case is wonderul). It would be see as an "extended if/while" rather than a general statement assignation. +1 on list comprehensions, even if I prefer the [(y, x/y) with y = f(x) for x in range(5)] or [(y, x/y) for x in range(5) with y =

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Rhodri James
On 02/03/18 11:43, Chris Angelico wrote: After dozens of posts and a wide variety of useful opinions and concerns being raised, here is the newest version of PEP 572 for your debating pleasure. I haven't said this yet, so thanks Chris for putting this all together. Even if the result is a

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Chris Angelico
On Fri, Mar 2, 2018 at 10:56 PM, Paul Moore wrote: > On 2 March 2018 at 11:43, Chris Angelico wrote: >> After dozens of posts and a wide variety of useful opinions and >> concerns being raised, here is the newest version of PEP 572 for your >> debating

Re: [Python-ideas] PEP 572 version 2: Statement-Local Name Bindings

2018-03-02 Thread Paul Moore
On 2 March 2018 at 11:43, Chris Angelico wrote: > After dozens of posts and a wide variety of useful opinions and > concerns being raised, here is the newest version of PEP 572 for your > debating pleasure. This is a distinct improvement - thanks for incorporating the varied