In [1]: def test(array, func):
...: midres = [x**2 for x in array]
...: return func(midres)
...:
In [2]: test([1,2,3], sum)
Out[2]: 14
In [3]: p = test([2,3], sum)
Is it possible to get to the midres that was calculated when obtaining the value of p (i.e. [4,9] in this case), but without altering the test function? Of course, p.midres doesn't work; but is there a way to get it without including midres in the return statement?
I've seen this question here but it doesn't really answer my question since I'd like to get to midres through p, if possible.
Thanks in advance.