Built-in functions and keyword arguments

Duncan Booth duncan.booth at invalid.invalid
Mon Oct 29 19:45:22 CET 2007


"J. Clifford Dyer" <jcd at sdf.lonestar.org> wrote:

>> I think you are being a little bit unfair here: help(len) says:
>> 
>> len(...)
>>     len(object) -> integer
>>     
>>     Return the number of items of a sequence or mapping.
>> 
>> which implies that the argument to len has the name 'object'
>> (although in fact it doesn't have a name). The OP was simply asking
>> about the difference in calling conventions, not proposing to write
>> code using 'object' as the argument name.
> 
> Hmm....  To my mind, that just implies that the *type* of the expected
> input is an object.  Just like the "-> integer" tells you that the
> type of the output is an integer.  If the documentation read
> "len(s=object) -> integer", then I would expect a keyword argument s
> typed as an object. 
> 

How do you interpret:

>>> help(__import__)
Help on built-in function __import__ in module __builtin__:

__import__(...)
    __import__(name, globals={}, locals={}, fromlist=[], level=-1) -> 
module
...
>>> help(int)
Help on class int in module __builtin__:

class int(object)
 |  int(x[, base]) -> integer
...

Can you find any case (other than a single parameter identified as 
'object') where you can interpret the help string as telling you the types 
of the parameters?



More information about the Python-list mailing list