You could replace the line `exec(code)` with `exec(code, locals().update(args))` and then it would be sufficient to do `string_list.append(name)` and you can remove the line `globals()['var_%s'%name] = value`.