I need to programmatically get the number of arguments that a function requires. With functions declared in modules this is trivial:
myfunc.func_code.co_argcount
But built-in functions don’t have the func_code attribute. Is there another way to do this? Otherwise I can’t use the built-ins and have to re-write them in my code.
[addition] Thanks for the responses, hope they’ll be useful. I have used Pypy instead.
Take a look at the function below copied from here. This may be the best you can do. Note the comments about
inspect.getargspec.