I've been trying to figure this out for multiple days now.. Basically I have a large list of functions that I want to wrap in another function, and then redefine the original function as that wrapped function; but to do so in a list. Example:
Wrapper = lambda f: lambda x,y: f(x+3, y+3)
Funcs = f1, f2, f3, f4
f1, f2, f3, f4 = np.vectorize(Wrapper)(Funcs) ### Works
Funcs = np.vectorize(Wrapper)(Funcs) ### Fails
*Funcs, = np.vectorize(Wrapper)(Funcs) ### Fails
*[f1, f2, f3, f4], = np.vectorize(Wrapper)(Funcs) ### Fails
[f1, f2, f3, f4] = np.vectorize(Wrapper)(Funcs) ### Fails
### Defining them as a list, tuple, or dict doesn't seem to help either
### Also attempted other approaches than np.vectorize, but all fail the same.
Also attempted iterators/maps, list/dict comprehensions, for loops, attempts to redefine function name, and even trying to redefine the functions in a loop as global variables - all fail. I've attempted every single looping/iteration python method I am aware of or that I can find reference to online.
Basically, why am I not able to redefine/reassign functions in a list/tuple/dict in a looping process? Anytime loop I attempt will execute without error, but when I go to call the function, it just calls the old function and not the redefined one - unless I redefine the functions in an explicitly stated way as indicated above.
Is there any way I can pass variables as memory address pointers? I am on the verge of trying to use Ctypes to remap the function by memory address, but I find it hard to believe that is the only option here.