+2  A: 
import inspect

print len(inspect.getargspec(sum)[0])
Ned Batchelder
+9  A: 

The inspect module is your friend; specifically inspect.getargspec which gives you information about a function's arguments:

>>> def sum(a,b,c):
...     return a + b + c
...
>>> import inspect
>>> argspec = inspect.getargspec(sum)
>>> print len(argspec.args)
3

argspec also contains details of optional arguments and keyword arguments, which in your case you don't have, but it's worth knowing about:

>>> print argspec
ArgSpec(args=['a', 'b', 'c'], varargs=None, keywords=None, defaults=None)
RichieHindle
+4  A: 

sum.func_code.co_argcount

singularity