1def to_string(node):
2 def actual_recursive(node):
3 nonlocal a_str # ~global, can modify surrounding function's scope.
4 a_str += str(node.val)
5 if node.next != None:
6 actual_recursive(node.next)
7 a_str = ''
8 actual_recursive(node)
9 return a_str
1globvar = 0
2
3def set_globvar_to_one():
4 global globvar # Needed to modify global copy of globvar
5 globvar = 1
6
7def print_globvar():
8 print(globvar) # No need for global declaration to read value of globvar
9
10set_globvar_to_one()
11print_globvar() # Prints 1