Hello,
I’m relatively new to Python and found myself going down a needless rabbit hole but I figured I would inquire about a more elegant way of doing something and hopefully learn something about python.
I have a lot of code with various functions with keyword arguments that I would like to create a wrapper to generate some statistics on the functions.
def getStatistics(fn, *args, numAverages=10, timeBetweenAvgs=gc.DELAY_50MS):
data = np.zeros(shape=numAverages)
for x in range(numAverages):
data[x] = fn(args)
time.sleep(timeBetweenAvgs)
print("Average = " + np.average(data))
print("Stdev = " + np.std(data))
The “fn”'s in questions almost all take keyword arguments and even if they didn’t I’m not even sure how to translate *args into arguments for the fn.
Hope that makes sense, I’m clearly lost.
Thanks!