I wanted to have the option to pass my arguments to a function in a concise manner. So instead of passing all arguments directly, I include them as parameters function definiton and pass all such arguments as Common_Args
. Then I do the following
for key, value in Common_args.items():
if key in locals():
globals()[key] = value
Here is the problem. Even though the control goes inside the if condition(checked with debugger), the parameter's value do not change, but it should, right? Guides have confirmed that this should work, and if I run single statements in my debugger, the value of the variable does change.
My function definition in more detail is
def plotLFPData1Channel(plotHandles=None, channelString="", stimulus_list=None, folderName=None, analysisType=None,
timeVals=None, plotColor=None, blRange=None, stRange=None, referenceChannelString=None,
badTrialNameStr=None, useCommonBadTrialsFlag=None ,*,Common_args=None):
# first we have to unpack common args
if Common_args is not None:
for key, value in Common_args.items():
if key in locals():
globals()[key] = value
and I call the function like so
result=plotLFPData1Channel(plotHandles=ax.flatten(), channelString=analogChannelString, stimulus_list=stimValsToUse,analysisType=analysisType,Common_args=commonArgs)
with commonArgs={"folderName":folderName , "timeVals":timeVals, "plotColor":plotColor, "blRange":blRange, "stRange":stRange, "referenceChannelString":referenceChannelString, "badTrialNameStr":badTrialNameStr, "useCommonBadTrialsFlag":useCommonBadTrialsFlag}