[Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Nathaniel Smith
PEP 3104 says: """ A shorthand form is also permitted, in which nonlocal is prepended to an assignment or augmented assignment: nonlocal x = 3 The above has exactly the same meaning as nonlocal x; x = 3. (Guido supports a similar form of the global statement [24].) """ The PEP metadata says it

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Guido van Rossum
On Fri, Jan 5, 2018 at 1:57 AM, Nathaniel Smith wrote: > PEP 3104 says: > > """ > A shorthand form is also permitted, in which nonlocal is prepended to > an assignment or augmented assignment: > > nonlocal x = 3 > > The above has exactly the same meaning as nonlocal x; x = 3. (Guido > supports a

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Random832
On Fri, Jan 5, 2018, at 10:47, Guido van Rossum wrote: > I don't recall (though someone with more time might find the discussion in > the archives or on the tracker). It was never implemented and I think it > shouldn't be. So we might as well update the PEP. It wouldn't be > particularly useful, si

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Guido van Rossum
Yeah, but I've changed my mind on this -- I think it's needless added complexity that helps save one line of code in very few use cases. And you don't really think the PEP endorses `nonlocal foo += 1` do you? On Fri, Jan 5, 2018 at 10:48 AM, Random832 wrote: > On Fri, Jan 5, 2018, at 10:47, Guid

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Nathaniel Smith
On Fri, Jan 5, 2018 at 7:47 AM, Guido van Rossum wrote: > I don't recall (though someone with more time might find the discussion in > the archives or on the tracker). It was never implemented and I think it > shouldn't be. So we might as well update the PEP. It wouldn't be > particularly useful,

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Guido van Rossum
I don't like those examples -- "nonlocal foo = bar" sounds like bar is used as the *initializer*, but it actually is just an assignment that overwrites the actual initial value. IMO those shouldn't be combined. On Fri, Jan 5, 2018 at 2:59 PM, Nathaniel Smith wrote: > On Fri, Jan 5, 2018 at 7:47

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Paul Moore
On 5 January 2018 at 23:02, Guido van Rossum wrote: > I don't like those examples -- "nonlocal foo = bar" sounds like bar is used > as the *initializer*, but it actually is just an assignment that overwrites > the actual initial value. IMO those shouldn't be combined. That was my immediate reacti

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-05 Thread Benjamin Peterson
On Fri, Jan 5, 2018, at 01:57, Nathaniel Smith wrote: > Was this just an oversight, or did it get rejected at some point and > no-one remembered to update that PEP? There was an implementation https://bugs.python.org/issue4199. But several years ago, we again reached the conclusion that the fe

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-06 Thread Guido van Rossum
Maybe we should not delete them outright but add something like "(UPDATE: during later discussions it was decided that this feature shouldn't be added.)" On Fri, Jan 5, 2018 at 10:52 PM, Benjamin Peterson wrote: > > > On Fri, Jan 5, 2018, at 01:57, Nathaniel Smith wrote: > > Was this just an ove

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-06 Thread Barry Warsaw
On Jan 6, 2018, at 11:43, Guido van Rossum wrote: > > Maybe we should not delete them outright but add something like "(UPDATE: > during later discussions it was decided that this feature shouldn't be > added.)" +1 -Barry signature.asc Description: Message signed with OpenPGP _

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-06 Thread Random832
On Fri, Jan 5, 2018, at 14:07, Guido van Rossum wrote: > Yeah, but I've changed my mind on this -- I think it's needless added > complexity that helps save one line of code in very few use cases. And you > don't really think the PEP endorses `nonlocal foo += 1` do you? The PEP itself is very clear

Re: [Python-Dev] Whatever happened to 'nonlocal x = y'?

2018-01-06 Thread Benjamin Peterson
https://github.com/python/peps/commit/2d2ac2d2b66d4e37e8b930f5963735616bddbbe8 On Sat, Jan 6, 2018, at 08:56, Barry Warsaw wrote: > On Jan 6, 2018, at 11:43, Guido van Rossum wrote: > > > > Maybe we should not delete them outright but add something like "(UPDATE: > > during later discussions it