Given the following code
a = 100
b = 200
snip = '''
c = a+b
'''
exec(snip)
print(c)
how can I pass values into exec, and get values out of exec, without using global scope?
In other words, instead of declaring a
, b
, and c
in global scope, how can I pass a
and b
into the snippet like a function, and get the result c