Given the following function:
def test(* p1=None, p2=None):
...
Called as follows:
test(p2="hello")
Can I programmatically obtain a list/dictionary of the arguments and their value at runtime?
1: Don't want to use **kwargs
because I want to force the user to use the proper argument names (and plan to do type annotation as well).
2: I've looked at the inspect
module for getting the defaults, but does not seem to let me see the run-time values.
Looking to create code something like this:
request = {k: v for k,v in __some_magic_location__ if v is not None}