'Get hold of variable value combining two strings

I would like to have dynamic parameters for a API im using. For that im searching for a easy way to achive the following:

def __init__(self):
    self.search_param_list = [from, to]
    self.from = A
    self.to = B

def search_params2(self):
    parameters = {parameter: self.parameter for parameter in self.search_param_list}
    return parameters

The output is expectet to look something like this:

parameters ={"from": A, "to": B}

I do this to change the params in the init if wanted, but that i dont have to do it if not nessesary.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source