How to get the number of args of a built-in function in Python? -


I need to get the number of arguments in the programmatic manner that the function is required in the modules, with the declared functions it is trivial Is:

  myfunc.func_code.co_argcount  

But in the underlying tasks func_code is there any other way to do this? Otherwise I can not use built-in and they will have to re-type in my code.

[Also] Thanks for the responses, hope they will be useful. I've used Pypy instead.

Take a look at the function given below. It may be best for you inspect Note the comments about .getargspec . Def description_billin (obje): "" "describe an underlying function" "('+ built-in function:% s' obj .__ name__) # Built-In Functions # by inspect.getargspec Do not be inspected, we have to try the __DOC__ attribute of the function. Docstr = obj .__ doc__ args = '' If docstr: item = docstr.split ('\ n') If item: func_descr = item [0] s = Func_descr.replace (obj .__name__, '') idx1 = s.find ('(') Idx2 = s.find (')', idx1) if idx1! = -1 and idx2! = -1 and (idx2 & Gt; idx1 + 1): args = s [idx1 + 1: idx2] wi ('\ t-method arguents:', args) if args == '': wi '(' \ t-law arguments Finalists: None) print


Comments