I want to use the num_samples
variable that I have defined in the make_averaged
function. When I use the variable in fun_averaged
it should search it in the scope of its upper level
function.
def make_averaged(fn, num_samples=1000):
def fun_averaged(*args) :
totalave = 0
savenum = num_samples
while not num_samples == 0:
totalave = fn(*args) + totalave
num_samples -= 1
avetagevalue = totalave/savenum
return avetagevalue
return fun_averaged
However I get an Error
while not samples1 == 0:
UnboundLocalError: local variable 'samples1' referenced before assignment