Code: Select all
def delVars(ts):
for s in ts:
st = "del %s" % s
print(st)
try:
exec(st, globals(), locals())
except Exception as e:
print(e)
Aber warum ist das? Ich überlasse Globals () an exec () , sodass es Zugriff auf Variablen außerhalb des Funktionsbereichs hat.