Python - Extract private variables from a function? -
i have function f2(a, b)
it ever called minimize algorithm iterates function different values of , b each time. store these iterations in excel plotting.
is possible extract these values (i need paste them excel or text file) easily? conventional return , print won't work within f2. there way extract values , b public list in main body other way?
the algorithm may iterate dozens or hundreds of times.
so far have tried:
print console (can't paste data excel easily)
write file (csv) within f2, csv file gets overwritten within function each time though.
append values global list.
values = [] def f2(a,b): values.append((a,b)) #todo: actual function logic goes here
then can @ values
in main scope once you're done iterating.
Comments
Post a Comment