Steve Dower added the comment:
This is intended behavior.
When a variable has an assignment anywhere in a function, it becomes a local.
Once a local variable exists, it will shadow the non-local variable.
So by having the "n =", you are marking "n" as a local variable. When the "n +
1" trie
Karthikeyan Singaravelan added the comment:
This tracker is for issues related to CPython. The examples presented in the
report look more like user error with variables where N is not defined in the
first examples. Can you please illustrate over the examples over how this is an
issue with in
New submission from Mahdi Jafary :
this code is ok
def test(t):
n = 0
def f(t):
print(t+str(N))
f(t)
test('test')
but this code have error
def test(t):
n = 0
def f(t):
n = n+1
print(t+str(n))
f(t