Is there any way in Python to build a dict from variable name/value to key/value without assigning explicitly?
def my_func(var1, var2):
my_dict = dict(var1 , var2)
print(my_dict)
my_func("x", "y")
Prints:
{"var1": "x", "var2": "y"}
Edited in order to make it less artificial. The idea is to avoid dict(var1=var1)