Effective Python: Introspection
programming
Python
effective python
Get the arguments of a function. Used in aggregate.distr.Aggregate
.
import inspect
def f(a, b, c, d):
= inspect.currentframe()
frame = inspect.getargvalues(frame).locals
spec for n in ['frame']:
if n in spec:
spec.pop(n)
# internal variables are ignored
= f = g = 999
e
return spec
1,2,3,4)
f(>>> {'a': 1, 'b': 2, 'c': 3, 'd': 4}