I basically want to expand the current scope as you would a dictionary when calling a function.
I remember seeing something about this somewhere but I cannot remember where or how to do it.
Here is a simple example
def bar(a, b, c, d, e, f):
pass
def foo(a, b, c, d, e, f):
# Instead of doing this
bar(a, b, c, d, e, f)
# or
bar(a=a, b=b, c=c, d=d, e=e, f=f)
# I'd like to do this
bar(**local_scope)
Am I imagining things or can this really be done?
You can use
locals()(orglobals()depending on what you need), which returns a dictionary mapping variable names to values.