2010/2/23 Hugo Arts
> On Tue, Feb 23, 2010 at 1:38 PM, Vladislav Vorobyov
> wrote:
> > #!/usr/bin/python
> > def func_outer():
> > x = 2
> > print('x is', x)
> > def func_inner():
> > nonlocal x
> > x = 5
> > func_inner()
> >
On Tue, Feb 23, 2010 at 1:38 PM, Vladislav Vorobyov
wrote:
> #!/usr/bin/python
> def func_outer():
> x = 2
> print('x is', x)
> def func_inner():
> nonlocal x
> x = 5
> func_inner()
> print('Changed local x to', x)
>
> func_ou
#!/usr/bin/python
def func_outer():
x = 2
print('x is', x)
def func_inner():
nonlocal x
x = 5
func_inner()
print('Changed local x to', x)
func_outer()
Output:
File "nonlocal_var.py", line 6
nonlocal x
^
Synta