When I write functions in Python, I typically need to pass quite a few variables to the function. Also, output of such functions contains more than a few variables. In order to manage this variables I/O, I resort to the dictionary datatype, where I pack all input variables into a dictionary to inject into a function and then compile another dictionary at the end of the function for returning to the main program. This of course needs another unpacking of the output dictionary.
dict_in = {'var1':var1,
           'var2':var2,
           'varn':varn}    
def foo(dict_in):
    var1 = dict_in['var1']
    var2 = dict_in['var2']
    varn = dict_in['varn']
    """ my code """
    dict_out = {'op1':op1,
                'op2':op2,
                'op_m':op_m}
    return dict_out
As the list of variables grows, I suspect that this will be an inefficient approach to deal with the variables I/O.
Can someone suggest a better, more efficient and less error-prone approach to this practice?
 
     
     
    