Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-11 Thread MRAB
On 2018-04-11 04:15, Mike Miller wrote: If anyone is interested I came across this same subject on a blog post and discussion on HN today: - https://www.hillelwayne.com/post/equals-as-assignment/ It says "BCPL also introduced braces as a means of defining blocks.". That bit is wrong, unless "

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-10 Thread Chris Angelico
On Wed, Apr 11, 2018 at 1:15 PM, Mike Miller wrote: > If anyone is interested I came across this same subject on a blog post and > discussion on HN today: > > - https://www.hillelwayne.com/post/equals-as-assignment/ > - https://news.ycombinator.com/item?id=16803874 Those people who say "x = x + 1

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-10 Thread Mike Miller
If anyone is interested I came across this same subject on a blog post and discussion on HN today: - https://www.hillelwayne.com/post/equals-as-assignment/ - https://news.ycombinator.com/item?id=16803874 On 2018-04-02 15:03, Guido van Rossum wrote: IIRC Algol-68 (the lesser-known, more complic

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-09 Thread Nick Coghlan
On 9 April 2018 at 01:01, Steven D'Aprano wrote: > On Sun, Apr 08, 2018 at 09:25:33PM +1000, Nick Coghlan wrote: > >> I was writing a new stdlib test case today, and thinking about how I >> might structure it differently in a PEP 572 world, and realised that a >> situation the next version of the

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-08 Thread Steve Dower
write.) Top-posted from my Windows phone From: Nick Coghlan Sent: Sunday, April 8, 2018 6:27 To: Chris Angelico Cc: python-ideas Subject: Re: [Python-ideas] PEP 572: Statement-Local Name Bindings,take three! On 23 March 2018 at 20:01, Chris Angelico wrote: > Apologies for letting this langu

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-08 Thread Guido van Rossum
On Sun, Apr 8, 2018 at 8:01 AM, Steven D'Aprano wrote: > If we really wanted to keep the sublocal scoping, we could make > list/set/dict displays their own scope too. > > Personally, that's the only argument for sublocal scoping that I like > yet: what happens inside a display should remain insid

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-08 Thread Steven D'Aprano
On Sun, Apr 08, 2018 at 09:25:33PM +1000, Nick Coghlan wrote: > I was writing a new stdlib test case today, and thinking about how I > might structure it differently in a PEP 572 world, and realised that a > situation the next version of the PEP should discuss is this one: > > # Dict display

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-08 Thread Nick Coghlan
On 23 March 2018 at 20:01, Chris Angelico wrote: > Apologies for letting this languish; life has an annoying habit of > getting in the way now and then. > > Feedback from the previous rounds has been incorporated. From here, > the most important concern and question is: Is there any other syntax >

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-02 Thread Mike Miller
Interesting, thanks. On 2018-04-02 15:03, Guido van Rossum wrote: ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-02 Thread Guido van Rossum
IIRC Algol-68 (the lesser-known, more complicated version) used 'int x = 0;' to declare a constant and 'int x := 0;' to declare a variable. And there was a lot more to it; see https://en.wikipedia.org/wiki/ALGOL_68#mode:_Declarations. I'm guessing Go reversed this because they want '=' to be the co

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-04-02 Thread Mike Miller
Yes, I first came across := when learning (Turbo) Pascal in the early 90's. However golang managed to screw it up—it only works there as a "short declaration AND assignment" operator. You can't use it twice on the same variable! Boggles the mind how experienced designers came up with that one

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-30 Thread Guido van Rossum
On Fri, Mar 30, 2018 at 12:04 PM, Nikolaus Rath wrote: > On Mar 25 2018, Guido van Rossum public.gmane.org> wrote: > > I gotta say I'm warming up to := in preference over 'as', *if* we're > going > > to do this at all (not a foregone conclusion at all). > > I'm surprised that no one has mentione

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-30 Thread Nikolaus Rath
On Mar 25 2018, Guido van Rossum wrote: > I gotta say I'm warming up to := in preference over 'as', *if* we're going > to do this at all (not a foregone conclusion at all). I'm surprised that no one has mentioned it yet, so as a quick datapoint: Go also uses := for assignment, so there's some pr

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread BrenBarn
On 03/23/2018 03:01 AM, Chris Angelico wrote: Apologies for letting this languish; life has an annoying habit of getting in the way now and then. My simple response to all of this is that it's not worth it. Each new example convinces me more and more that in almost every case, sublocal assi

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Guido van Rossum
This thread is dead. On Tue, Mar 27, 2018 at 5:40 PM, Rob Cliffe via Python-ideas < python-ideas@python.org> wrote: > > > On 28/03/2018 01:19, Steven D'Aprano wrote: > >> On Wed, Mar 28, 2018 at 12:08:24AM +0100, Rob Cliffe via Python-ideas >> wrote: >> >>> On 27/03/2018 16:22, Guido van Rossum w

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Rob Cliffe via Python-ideas
On 28/03/2018 01:19, Steven D'Aprano wrote: On Wed, Mar 28, 2018 at 12:08:24AM +0100, Rob Cliffe via Python-ideas wrote: On 27/03/2018 16:22, Guido van Rossum wrote: The standard reply here is that if you can't tell at a glance whether that's the case, your code is too complex. The Zen of Pyt

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Steven D'Aprano
On Wed, Mar 28, 2018 at 12:08:24AM +0100, Rob Cliffe via Python-ideas wrote: > > On 27/03/2018 16:22, Guido van Rossum wrote: > >The standard reply here is that if you can't tell at a glance whether > >that's the case, your code is too complex. The Zen of Python says > >"Namespaces are one honk

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Rob Cliffe via Python-ideas
On 27/03/2018 16:22, Guido van Rossum wrote: On Tue, Mar 27, 2018 at 7:00 AM, Nick Coghlan > wrote: On 27 March 2018 at 01:57, Guido van Rossum mailto:gu...@python.org>> wrote: > On Mon, Mar 26, 2018 at 7:57 AM, Nick Coghlan mailto:ncogh...@gmail.com>> wr

[Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Cammil Taank
> > ... From here, > the most important concern and question is: Is there any other syntax > or related proposal that ought to be mentioned here? I am not sure if this is valid, but perhaps this is an alternative syntax which might be simpler: ``name! expr`` So for example, instead of: stu

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Guido van Rossum
On Tue, Mar 27, 2018 at 7:00 AM, Nick Coghlan wrote: > On 27 March 2018 at 01:57, Guido van Rossum wrote: > > On Mon, Mar 26, 2018 at 7:57 AM, Nick Coghlan > wrote: > >> By contrast, the sublocals idea strives to keep the *lifecycle* impact > >> of naming a subexpression as negligible as possib

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Kyle Lahnakoski
On 2018-03-23 06:01, Chris Angelico wrote: > https://www.python.org/dev/peps/pep-0572/ > A suggestion: Under the rejected "Special-casing comprehensions", you show "prefix-local-name-bindings": Name bindings that appear before the loop, like: > stuff = [(y, x/y) where y = f(x) for x in range(5

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-27 Thread Nick Coghlan
On 27 March 2018 at 01:57, Guido van Rossum wrote: > On Mon, Mar 26, 2018 at 7:57 AM, Nick Coghlan wrote: >> By contrast, the sublocals idea strives to keep the *lifecycle* impact >> of naming a subexpression as negligible as possible - while a named >> subexpression might live a little longer th

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Tim Peters
[Guido] > ... > Not so fast. There's a perfectly reasonable alternative to sublocal scopes > -- just let it assign to a local variable in the containing scope. That's > the same as what Python does for for-loop variables. That's certainly what I would _expect_ if I never read the docs, conditioned

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread BrenBarn
On 03/26/2018 04:18 AM, Steven D'Aprano wrote: On Mon, Mar 26, 2018 at 11:14:43AM +0300, Kirill Balunov wrote: Hi Chris, would you mind to add this syntactic form `(expr -> var)` to alternative syntax section, with the same semantics as `(expr as var)`. It seems to me that I've seen this form pr

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Steven D'Aprano
On Mon, Mar 26, 2018 at 03:33:52PM +0100, Rhodri James wrote: > While my crystal ball is cloudy, I can well imagine beginners becoming > very confused over which symbol to use in which circumstance, and a lot > of swearing when: > > x := f() > if (y = g(x)) is not None: > h(y) > > res

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Rob Cliffe via Python-ideas
On 26/03/2018 16:57, Guido van Rossum wrote: On Mon, Mar 26, 2018 at 7:57 AM, Nick Coghlan > wrote: On 26 March 2018 at 14:34, Guido van Rossum mailto:gu...@python.org>> wrote: > Not so fast. There's a perfectly reasonable alternative to sublocal scopes

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Guido van Rossum
On Mon, Mar 26, 2018 at 7:57 AM, Nick Coghlan wrote: > On 26 March 2018 at 14:34, Guido van Rossum wrote: > > Not so fast. There's a perfectly reasonable alternative to sublocal > scopes > > -- just let it assign to a local variable in the containing scope. That's > > the same as what Python doe

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Nick Coghlan
On 26 March 2018 at 14:34, Guido van Rossum wrote: > Not so fast. There's a perfectly reasonable alternative to sublocal scopes > -- just let it assign to a local variable in the containing scope. That's > the same as what Python does for for-loop variables. Note that for > comprehensions it still

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Rhodri James
On 26/03/18 02:24, Guido van Rossum wrote: I gotta say I'm warming up to := in preference over 'as',*if* we're going to do this at all (not a foregone conclusion at all). I have the usual objection to glyphs (hard to look up or get help on), but ":=" raises two issues all of its own. * On t

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Steven D'Aprano
On Mon, Mar 26, 2018 at 02:42:32PM +0300, Kirill Balunov wrote: > I was also thinking about `<-` variant (but with a Haskell in mind), but > with the current Python rules, it seems that it does not fit: Ah, of course not, the dreaded unary operator strikes again! (I was just chatting with Chris

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Kirill Balunov
2018-03-26 14:18 GMT+03:00 Steven D'Aprano : > That was probably my response to Nick: > > https://mail.python.org/pipermail/python-ideas/2018-March/049472.html > > I compared four possible choices: > > target = default if (expression as name) is None else name > target = default if (name :

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Steven D'Aprano
On Mon, Mar 26, 2018 at 11:14:43AM +0300, Kirill Balunov wrote: > Hi Chris, would you mind to add this syntactic form `(expr -> var)` to > alternative syntax section, with the same semantics as `(expr as var)`. It > seems to me that I've seen this form previously in some thread (can't find > where)

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Chris Angelico
On Mon, Mar 26, 2018 at 7:14 PM, Kirill Balunov wrote: > Hi Chris, would you mind to add this syntactic form `(expr -> var)` to > alternative syntax section, with the same semantics as `(expr as var)`. It > seems to me that I've seen this form previously in some thread (can't find > where), but it

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-26 Thread Kirill Balunov
Hi Chris, would you mind to add this syntactic form `(expr -> var)` to alternative syntax section, with the same semantics as `(expr as var)`. It seems to me that I've seen this form previously in some thread (can't find where), but it does not appear in alt. syntax section. As for me this form has

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Chris Angelico
On Mon, Mar 26, 2018 at 3:34 PM, Guido van Rossum wrote: > On Sun, Mar 25, 2018 at 6:29 PM, Chris Angelico wrote: >> >> On Mon, Mar 26, 2018 at 12:24 PM, Guido van Rossum >> wrote: >> > The scope question is far from easy though. I find it particularly >> > grating >> > that an inline assignment

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Guido van Rossum
On Sun, Mar 25, 2018 at 6:29 PM, Chris Angelico wrote: > On Mon, Mar 26, 2018 at 12:24 PM, Guido van Rossum > wrote: > > The scope question is far from easy though. I find it particularly > grating > > that an inline assignment occurs in an 'if' statement, its scope is the > > entire body of the

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Tim Peters
[Tim] >> I wonder whether Guido remembers this ;-) In the very, very, VERY >> early days, Python didn't have "==". Plain single "=" was used for >> both assignment and equality testing. [Guido] > Wow, I did not remember this. In fact I had to track down the 0.9.1 release > that's somewhere on th

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Chris Angelico
On Mon, Mar 26, 2018 at 12:24 PM, Guido van Rossum wrote: > I gotta say I'm warming up to := in preference over 'as', *if* we're going > to do this at all (not a foregone conclusion at all). So am I, primarily due to its lack of syntactic ambiguities. > The scope question is far from easy though

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Guido van Rossum
On Sun, Mar 25, 2018 at 4:40 PM, Tim Peters wrote: > [Chris Angelico ] > > ... > > Not qualitative, but anecdotal: I do sometimes have to remind my > > JavaScript students to check whether they've typed enough equals > > signs. And that's in a language where the normal comparison operator > > is

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Chris Angelico
On Mon, Mar 26, 2018 at 10:40 AM, Tim Peters wrote: > Here's one that baffled an office full of MIT grads for half a day > before I noticed the real problem: > > assert(n=2); > > You can fill in the rest of the story yourself - but you'll miss the > full extent of the agony it caused ;-) I ha

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Tim Peters
[Chris Angelico ] > ... > Not qualitative, but anecdotal: I do sometimes have to remind my > JavaScript students to check whether they've typed enough equals > signs. And that's in a language where the normal comparison operator > is ===. It's *still* not uncommon to see a comparison spelled =. I

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Guido van Rossum
On Sun, Mar 25, 2018 at 12:18 AM, Chris Angelico wrote: > [...] > Agreed. I'm currently thinking that I need to do what several people > have suggested and break this into two completely separate PEPs: > > 1) Sublocal namespacing > 2) Assignment expressions > > Sublocal names can be used in a num

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Zero Piraeus
: On 25 March 2018 at 02:34, Guido van Rossum wrote: > [...] I think we need a short, crisp name for the new variable type. Disposables? -[]z. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Steven D'Aprano
On Sun, Mar 25, 2018 at 05:00:37PM +1000, Nick Coghlan wrote: > Given the existing namespace stack of > builtin<-global<-nonlocal<-local, one potential short name would be > "sublocal", to indicate that these references are even more local than > locals (they're *so* local, they don't even appe

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Nick Coghlan
On 25 March 2018 at 17:18, Chris Angelico wrote: > Agreed. I'm currently thinking that I need to do what several people > have suggested and break this into two completely separate PEPs: > > 1) Sublocal namespacing > 2) Assignment expressions > > Sublocal names can be used in a number of ways. The

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Chris Angelico
On Sun, Mar 25, 2018 at 4:34 PM, Guido van Rossum wrote: > This is a super complex topic. There are at least three separate levels of > critique possible, and all are important. Thank you for your detailed post. I'll respond to some of it here, and some more generally below. > First there is the

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-25 Thread Nick Coghlan
On 25 March 2018 at 15:34, Guido van Rossum wrote: > > This is a super complex topic. There are at least three separate levels of > critique possible, and all are important. > > First there is the clarity of the PEP. Steven D'Aprano has given you great > detailed feedback here and you should tak

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Guido van Rossum
This is a super complex topic. There are at least three separate levels of critique possible, and all are important. First there is the clarity of the PEP. Steven D'Aprano has given you great detailed feedback here and you should take it to heart (even if you disagree with his opinion about the sp

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Ethan Furman
On 03/24/2018 09:27 AM, Rob Cliffe via Python-ideas wrote: On 24/03/2018 14:44, Steven D'Aprano wrote: On Sat, Mar 24, 2018 at 07:12:49PM +1000, Nick Coghlan wrote: For PEP 572, the most directly comparable example is code like this: # Any previous binding of "m" is lost completely on t

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Ethan Furman
On 03/24/2018 07:44 AM, Steven D'Aprano wrote: I don't think we need sub-function scoping. I think it adds more complexity that outweighs whatever benefit it gives. +1 -- ~Ethan~ ___ Python-ideas mailing list Python-ideas@python.org https://mail.py

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Rob Cliffe via Python-ideas
On 24/03/2018 16:02, Steven D'Aprano wrote: Yes, I get functions, and I think function-scope is a sweet spot between too few scopes and too many. Remember the bad old days of BASIC when all variables were application-global? Even if you used GOSUB as a second-rate kind of function, all the var

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Rob Cliffe via Python-ideas
On 24/03/2018 14:44, Steven D'Aprano wrote: On Sat, Mar 24, 2018 at 07:12:49PM +1000, Nick Coghlan wrote: [...] At a user experience level, the aim of the scoping limitation is essentially to help improve "code snippet portability". Consider the following piece of code: squares = [x**2

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Steven D'Aprano
On Sat, Mar 24, 2018 at 08:49:08PM +1100, Chris Angelico wrote: > > [(spam, spam+1) for x in values for spam in (func(x),)] > > > > [(spam, spam+1) for spam in (func(x) for x in values)] > > > > They are the equivalent to "just add another assignment statement" for > > comprehensions. > >

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Steven D'Aprano
On Sat, Mar 24, 2018 at 07:12:49PM +1000, Nick Coghlan wrote: > > I think that needs justification by more than just "it makes the > > implementation easier". > > Introducing the new scoping behaviour doesn't make the implementation > easier, it makes it harder. [...] Perhaps I had misunderstood

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Eric V. Smith
On 3/24/2018 5:49 AM, Chris Angelico wrote: On Sat, Mar 24, 2018 at 3:41 PM, Steven D'Aprano wrote: To keep this a manageable length, I've trimmed vigourously. Apologies in advance if I've been too enthusiastic with the trimming :-) On Sat, Mar 24, 2018 at 05:09:54AM +1100, Chris Angelico wrote

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Paul Moore
On 24 March 2018 at 09:49, Chris Angelico wrote: >> Of course we don't want to necessarily impose unreasonable performance >> and maintence costs on any implementation. But surely performance >> cost is a quality of implementation issue. It ought to be a matter of >> trade-offs: is the benefit suf

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Chris Angelico
On Sat, Mar 24, 2018 at 3:41 PM, Steven D'Aprano wrote: > To keep this a manageable length, I've trimmed vigourously. Apologies in > advance if I've been too enthusiastic with the trimming :-) > > On Sat, Mar 24, 2018 at 05:09:54AM +1100, Chris Angelico wrote: > >> No, I haven't yet. Sounds like a

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Nick Coghlan
On 24 March 2018 at 14:41, Steven D'Aprano wrote: > On Sat, Mar 24, 2018 at 05:09:54AM +1100, Chris Angelico wrote: > > >> Just as function-local names shadow global names for the scope of the > > >> function, statement-local names shadow other names for that statement. > > >> (They can technical

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-24 Thread Nick Coghlan
On 24 March 2018 at 04:09, Chris Angelico wrote: > On Sat, Mar 24, 2018 at 2:00 AM, Steven D'Aprano > wrote: > > I see you haven't mentioned anything about Nick Coglan's (long ago) > > concept of a "where" block. If memory serves, it would be something > > like: > > > > value = x**2 + 2*x wh

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-23 Thread Steven D'Aprano
To keep this a manageable length, I've trimmed vigourously. Apologies in advance if I've been too enthusiastic with the trimming :-) On Sat, Mar 24, 2018 at 05:09:54AM +1100, Chris Angelico wrote: > No, I haven't yet. Sounds like a new section is needed. Thing is, > there's a HUGE family of C-li

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-23 Thread Chris Angelico
On Sat, Mar 24, 2018 at 2:00 AM, Steven D'Aprano wrote: > On Fri, Mar 23, 2018 at 09:01:01PM +1100, Chris Angelico wrote: > >> PEP: 572 >> Title: Syntax for Statement-Local Name Bindings > [...] >> Abstract >> >> >> Programming is all about reusing code rather than duplicating it. > > I d

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-23 Thread Steven D'Aprano
On Fri, Mar 23, 2018 at 09:01:01PM +1100, Chris Angelico wrote: > PEP: 572 > Title: Syntax for Statement-Local Name Bindings [...] > Abstract > > > Programming is all about reusing code rather than duplicating it. I don't think that editorial comment belongs here, or at least, it is wa

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-23 Thread Rhodri James
On 23/03/18 10:01, Chris Angelico wrote: Apologies for letting this languish; life has an annoying habit of getting in the way now and then. Feedback from the previous rounds has been incorporated. From here, the most important concern and question is: Is there any other syntax or related propos

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-23 Thread Chris Angelico
On Fri, Mar 23, 2018 at 9:38 PM, Paul Moore wrote: > On 23 March 2018 at 10:01, Chris Angelico wrote: >> # ... except when function bodies are involved... >> if (input("> ") as cmd): >> def run_cmd(): >> print("Running command", cmd) # NameError >> >> # ... but fun

Re: [Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-23 Thread Paul Moore
On 23 March 2018 at 10:01, Chris Angelico wrote: > # ... except when function bodies are involved... > if (input("> ") as cmd): > def run_cmd(): > print("Running command", cmd) # NameError > > # ... but function *headers* are executed immediately > if (input(">

[Python-ideas] PEP 572: Statement-Local Name Bindings, take three!

2018-03-23 Thread Chris Angelico
Apologies for letting this languish; life has an annoying habit of getting in the way now and then. Feedback from the previous rounds has been incorporated. From here, the most important concern and question is: Is there any other syntax or related proposal that ought to be mentioned here? If this