my_var = 'bla';
api_key = 'key';
...lots of code here...
params = {"language": "en", my_var: api_key}
If you are used to JavaScript, variable evaluation in Python dictionaries won't be what you expect it to be. This statement in JavaScript would result in the params
object as follows:
{
"language": "en",
"my_var": "key"
}
In Python, however, it would result in the following dictionary:
{
"language": "en",
"bla": "key"
}
my_var
is evaluated and its value is used as the key.