auto-handles original *args and **kwargs. Use it like recurse_ex(myfunc,locals(),changed=changed-1)
(func, func_locals, **kwargs)
| 26 | return func(*args,**kwargs) |
| 27 | |
| 28 | def recurse_ex(func, func_locals, **kwargs): |
| 29 | """auto-handles original *args and **kwargs. |
| 30 | Use it like recurse_ex(myfunc,locals(),changed=changed-1) |
| 31 | """ |
| 32 | co=func.func_code |
| 33 | args = tuple([ kwargs.pop(co.co_varnames[i], func_locals[co.co_varnames[i]]) |
| 34 | for i in range(co.co_argcount) ]) |
| 35 | if co.co_flags & 0x04: |
| 36 | i+=1 |
| 37 | args+=func_locals[co.co_varnames[i]] |
| 38 | if co.co_flags & 0x08: |
| 39 | kwargs.update(func_locals[co.co_varnames[i+1]]) #TODO:reverse priority? |
| 40 | return func(*args,**kwargs) |
| 41 | |
| 42 | def recursor(func, func_locals): |
| 43 | co=func.func_code |