[Tutor] constructing semi-arbitrary functions

Dave Angel davea at davea.name
Wed Feb 19 13:57:04 CET 2014


On 02/19/2014 07:33 AM, Oscar Benjamin wrote:

>
> At the least I don't understand why it needs both the argument names
> and the number of arguments as independent quantities. Surely
> len(names) would be the number of arguments... Or am I missing
> something?
>

In the standard library, the attributes are
   func_code.co_varnames

and
   func_code.co_argcount

Note that varnames will include all the locals, not just the formal 
parameters.  So the count tells you how many of them are parameters.

-- 
DaveA



More information about the Tutor mailing list