Say I want to do the following:
name = 1.2
The thing is that the literal name of 'name' is provided on-the-fly (it could be 'mike=1.2', 'john=1.2',...)
Hope I explained my question, and thanks in advance for any hint.
Say I want to do the following:
name = 1.2
The thing is that the literal name of 'name' is provided on-the-fly (it could be 'mike=1.2', 'john=1.2',...)
Hope I explained my question, and thanks in advance for any hint.
You can use globals() or locals() depending on the scope needed:
>>> globals()['foo'] = 'bar'
>>> foo
'bar'
If you're asking this questions, however, it means you're doing something wrong - generating variables is essentially a bad idea. You should use structures such as a dictionary for this.