I want a function, such that I send it a name (as string), and this function create a variable with that name and set its value to, say 5. That's it. When the function is done I should be able to access that variable in the main program.
To make a variable declared inside a function available outside, I use global. That's about as much as went with it. Here's my attempt for what its worth.
def func(name='a'):
global exec(name)
exec( name + '=5' )
func()
# now I should be able to access the variable a
It is not working BTW. PS: I know that the easy way is to just make the function return that thing and I assign it to whatever I want. But I want to do it the way I describe above.