fix get_func_args error and update the doc

This commit is contained in:
Prodesire 2017-11-19 10:54:39 +08:00
parent ccda1ad515
commit 7b38d15cdc
2 changed files with 13 additions and 11 deletions

View File

@ -11,10 +11,12 @@ Inspect
``defaults`` is an n-tuple of the default values of the last n arguments.
>>> from pydu.inspect import getargspec
>>> def f(a, b=1, *c, **d):
>>> def f(name, address='home', age=25, *args, **kwargs):
... pass
...
>>> getargspect(f)
ArgSpec(args=['a', 'b'], varargs='c', keywords='d', defaults=(1,))
ArgSpec(args=['name', 'address', 'age'], varargs='args', keywords='kwargs', defaults=('home', 25))
.. py:function:: pydu.inspect.get_func_args(func)

View File

@ -16,7 +16,7 @@ if PY2:
def get_func_args(func):
argspec = inspect.getargspec(func)
if inspect.ismethod(func):
return argspec[1:] # ignore 'self'
return argspec.args[1:] # ignore 'self'
return argspec.args