Код: Выделить всё
def delVars(ts):
for s in ts:
st = "del %s" % s
print(st)
try:
exec(st, globals(), locals())
except Exception as e:
print(e)
Но почему это? Я передаю Globals () to exec () , поэтому он имеет доступ к переменным вне сферы функции.
Подробнее здесь: https://stackoverflow.com/questions/794 ... n-function