while i was reading about namespacing and scopping in python, i read that
-the innermost scope, which is searched first, contains the local names
-the scopes of any enclosing functions, which are searched starting with the nearest enclosing scope, contains non-local, but also non-global names
-the next-to-last scope contains the current module’s global names
-the outermost scope (searched last) is the namespace containing built-in names
but when i tried this :
def test() :
name = 'karim'
def tata() :
print(name)
name='zaka'
print(name)
tata()
i have received this error :
UnboundLocalError: local variable 'name' referenced before assignment
when the statement print(name) the tata() function will not find name in the current scope so python will go up in scope and find it in test() function scope no??