Dynamically get the paramters of a function from the dictionary

Viewed 24
dict = {
"target_variable" : { 
"A" : "col1",
"B":"col2",
"C": "col3",
"D": "col4",
"E": "col5",
"F": "col6",
"APPLE":"apple"
"ORANGE" :"orange"
"GRAPES" :"grapes"
"PINEAPPLE":"pineapple"}

def func(APPLE=None,GRAPES=None,PINEPAPPLE=None,ORANGE=None):
  APPLE.append("")
            GRAPES.append("")
            PINEAPPLE.append("")
            ORANGE.append("")
  res = fetch_data(
                apple=APPLE,
                pin=PINEPAPPLE,
                orange=ORANGE)

I want to re-write the same such that we can append the parameters to a list in the dictionary dict and dynamically paramters can be retrieved, without having to touch the funtion. Is this possible? The use case is that as and when paramters increase or decrease we can just do away with making (appending) in the dict rather than the fucntion

config = {
"target_variable" : { 
"A" : "col1",
"B":"col2",
"C": "col3",
"D": "col4",
"E": "col5",
"F": "col6",
"fruits" :["apple","orange","grapes","pineapple"]}

def func(**kwargs):

0 Answers
Related