Number of args in a function

Skip Montanaro skip at pobox.com
Tue Oct 16 16:48:01 EDT 2001


    Mark> Given a function f, how many arguments does it take?

>>> def foo(a,b,c,*args,**kwds):
...   pass
... 
>>> foo.func_code
<code object foo at 0x8193168, file "<stdin>", line 1>
>>> foo.func_code.co_nlocals
5
>>> foo.func_code.co_varnames
('a', 'b', 'c', 'args', 'kwds')

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list