In Python, help(functionName)
and functionName?
return all documentation for a given function, which is often too much text on the command line. Is there a way to return only the input parameters?
R's str()
does this, and I use it all the time.
The closest thing in Python would probably be to create a function based off of inspect.getargspec
, possibly via inspect.formatargspec
.
import inspect
def rstr(func):
return inspect.formatargspec(*inspect.getargspec(func))
This gives you an output like this:
>>> def foo(a, b=1): pass
...
>>> rstr(foo)
'(a, b=1)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With