Last active
October 10, 2015 21:48
-
-
Save PiDelport/3756230 to your computer and use it in GitHub Desktop.
Format a function call as a string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
def format_call(func, *positional, **named): | |
_locals = inspect.getcallargs(func, *positional, **named) | |
spec = inspect.getargspec(func) | |
argvalues = inspect.formatargvalues(spec.args, spec.varargs, spec.keywords, _locals) | |
return '{}{}'.format(func.__name__, argvalues) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Mirrored at https://bitbucket.org/snippets/pjdelport/ojBE.)