Asignación dinámica global de variables
Soy nuevo en Python y tengo muchos problemas para usarglobal
instrucción.
Aquí hay un ejemplo de código:
mouse = "a"
background = "b"
list_ab = [mouse, background]
def func ():
for item in list_ab:
global item # I want to modify the GLOBAL item, which is mouse
# and background.
item = "modified"
print mouse # must be "modified" not "a"
print background # must be "modified" not "b"
Este es el problema. ¿Cómo puedo resolverlo?