Chris Angelico wrote:
wants_one_arg.__code__.co_argcount
1
wants_one_arg.__code__.co_varnames
('x',)
That will give you some idea, but it's not foolproof -- e.g.
if the function has * or ** arguments, it's impossible to tell
in general how many arguments it accepts without studying the
code (and maybe not even then -- halting problem, etc.)
Some of the co_flags seem to indicate presence of * and **:
0x04 - has *args
0x08 - has **kwds
In Py3 there is also co_kwonlyargcount.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list