Re: [Python-ideas] Give nonlocal the same creating power as global

2017-09-12 Thread Chris Angelico
On Tue, Sep 12, 2017 at 8:54 PM, Nick Coghlan wrote: > On 12 September 2017 at 03:32, João Matos wrote: >> Hello, >> >> You're correct. The idea is to give nonlocal the same ability, redirect >> subsequent bindings if the variable doesn't exist. > > The issue you're facing is that optimised local

Re: [Python-ideas] Give nonlocal the same creating power as global

2017-09-12 Thread Nick Coghlan
On 12 September 2017 at 03:32, João Matos wrote: > Hello, > > You're correct. The idea is to give nonlocal the same ability, redirect > subsequent bindings if the variable doesn't exist. The issue you're facing is that optimised local variables still need to be defined in the compilation unit whe

Re: [Python-ideas] Give nonlocal the same creating power as global

2017-09-11 Thread João Matos
Hello, You're correct. The idea is to give nonlocal the same ability, redirect subsequent bindings if the variable doesn't exist. No, what I said is that it would only create the var if it didn't exist. That means that the current behaviour of nonlocal to check all previous envs (except globa

Re: [Python-ideas] Give nonlocal the same creating power as global

2017-09-11 Thread Terry Reedy
On 9/11/2017 10:03 AM, João Matos wrote: Hello, I would like to suggest that nonlocal should be given the same creating power as global. If I do global a_var it creates the global a_var if it doesn't exist. The global declaration does not create anything, but it redirects subsequent binding

Re: [Python-ideas] Give nonlocal the same creating power as global

2017-09-11 Thread Jason H
> Sent: Monday, September 11, 2017 at 10:03 AM > From: "João Matos" > To: python-ideas@python.org > Subject: [Python-ideas] Give nonlocal the same creating power as global > > Hello, > > I would like to suggest that nonlocal should be given the same crea

[Python-ideas] Give nonlocal the same creating power as global

2017-09-11 Thread João Matos
Hello, I would like to suggest that nonlocal should be given the same creating power as global. If I do global a_var it creates the global a_var if it doesn't exist. I think it would be great that nonlocal maintained that power. This way when I do nonlocal a_var it would create a_var in

[Python-ideas] Give nonlocal the same creating power as global

2017-09-11 Thread João Matos
Hello, I would like to suggest that nonlocal should be given the same creating power as global. If I do global a_var it creates the global a_var if it doesn't exist. I think it would be great that nonlocal maintained that power. This way when I do nonlocal a_var it would create a_var in the i