When a function is called, I would like to print the names and values of it's parameters. Something like:
>>> def foo(bar, baz):
>>> print_func_params()
>>>foo(5, 'test')
>>>bar=5, baz='test'
Right now I do it manually:
print(f"bar={bar},baz={baz}")
But this is a pain because as new parameters get added there's always the risk of missing something.
For context, this code is used for debugging a hardware interface. When the hardware isn't present it prints the IO instead of sending it to the hardware. This code lets me see the full sequence of commands that are being sent without needing the hardware present.
I found this answer which can work for single variables when you know what they are (and uses eval). I'd really like to avoid eval and be able to do it for an unknown set of parameters.