














Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!















Last updated on 28/07/2020 09:
FUNCTIONS II
1. Title
1. Title
Resolving
FUNCTIONS II
1. Title
Scope
1. Resolving variables enclosing namespace Title A_CONSTANT = 3 def outer(): def inner(): a_variable = 7 print(a_variable) another_variable = 2 print(another_variable) inner() outer() print(A_CONSTANT)
def outer(): def inner(): print(another_variable) another_variable = 2 print(another_variable) inner() outer()
def outer(): def inner(): print(A_CONSTANT) another_variable = 2 print(another_variable) inner() outer()
1. Resolving variables in the global namespace Title A_CONSTANT = 3 def outer(): def inner(): a_variable = 7 print(a_variable) another_variable = 2 print(another_variable) inner() outer() print(A_CONSTANT)
def outer(): def inner(): print(another_variable) another_variable = 2 print(another_variable) inner() outer()
def outer(): def inner(): print(A_CONSTANT) another_variable = 2 print(another_variable) inner() outer()
1. Title
Resolution, summary
1. Scope, summary Title
FUNCTIONS II
1. Title
1. Shadowing Title _# This generates an Exception, because global_var is defined in the
def my_funciton(): local_var = 2 print(global_var, local_var) global_var = 3 global_var = 1 my_funciton() Exception (error)
1. Shadowing (II) Title _# This does not generate an error, but, again, local_var
def outer(): def inner(): local_var = 7 print(local_var) local_var = 2 print(local_var) inner() print(local_var) outer()