Re: [Python-ideas] Sublocal scoping at its simplest

2018-04-30 Thread Chris Angelico
On Mon, Apr 30, 2018 at 6:20 PM, Matt Arcidy wrote: > Does this mean indentation is now a scope, or colons are a scope, or is that > over simplifying? No, no, and yes. This is JUST about the 'except' statement, which currently has the weird effect of unbinding the name it just

Re: [Python-ideas] Sublocal scoping at its simplest

2018-04-30 Thread Matt Arcidy
On Sat, Apr 28, 2018, 20:16 Chris Angelico wrote: > There's been a lot of talk about sublocal scopes, within and without > the context of PEP 572. I'd like to propose what I believe is the > simplest form of sublocal scopes, and use it to simplify one specific > special case in

Re: [Python-ideas] Sublocal scoping at its simplest

2018-04-29 Thread Greg Ewing
Chris Angelico wrote: 1) Bind the caught exception to a sublocal 'e' 2) Execute the suite, with the reference to 'e' seeing the sublocal 3) Set the sublocal e to None 4) Unbind the sublocal e At the unindent, the sublocal name will vanish, and the original 'e' will reappear. That's a

Re: [Python-ideas] Sublocal scoping at its simplest

2018-04-29 Thread Nick Coghlan
On 29 April 2018 at 21:24, Chris Angelico wrote: > On Sun, Apr 29, 2018 at 6:03 PM, Nick Coghlan wrote: > > The challenge with doing this implicitly is that there's no indication > > whatsoever that the two "e"'s are different, especially given the > >

Re: [Python-ideas] Sublocal scoping at its simplest

2018-04-29 Thread Chris Angelico
On Sun, Apr 29, 2018 at 6:03 PM, Nick Coghlan wrote: > The challenge with doing this implicitly is that there's no indication > whatsoever that the two "e"'s are different, especially given the > longstanding precedent that the try/except level one will overwrite any >

Re: [Python-ideas] Sublocal scoping at its simplest

2018-04-29 Thread Nick Coghlan
On 29 April 2018 at 13:14, Chris Angelico wrote: > There's been a lot of talk about sublocal scopes, within and without > the context of PEP 572. I'd like to propose what I believe is the > simplest form of sublocal scopes, and use it to simplify one specific > special case in

Re: [Python-ideas] Sublocal scoping at its simplest

2018-04-28 Thread Steven D'Aprano
On Sun, Apr 29, 2018 at 01:14:54PM +1000, Chris Angelico wrote: [...] > def f(): > e = 2.71828 > try: > 1/0 > except Exception as e: > print(e) > print(e) > f() > I propose to change the semantics as follows: > > 1) Bind the caught exception to a sublocal 'e' >

[Python-ideas] Sublocal scoping at its simplest

2018-04-28 Thread Chris Angelico
There's been a lot of talk about sublocal scopes, within and without the context of PEP 572. I'd like to propose what I believe is the simplest form of sublocal scopes, and use it to simplify one specific special case in Python. There are no syntactic changes, and only a very slight semantic