mirror of https://github.com/flaggo/pydu.git
fix get_func_args error and update the doc
This commit is contained in:
parent
ccda1ad515
commit
7b38d15cdc
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue