What value should be passed to make a function use the default argument value?

Georg Brandl g.brandl-nospam at gmx.net
Wed Oct 4 17:03:37 EDT 2006


Paul Rubin wrote:
> Antoon Pardon <apardon at forel.vub.ac.be> writes:
>> repeat(object[, times])
>>     Make an iterator that returns object over and over again. Runs
>>     indefinitely unless the times argument is specified. ...
>> 
>> My first impression from this, is that it is possible to call
>> this as follows:
>>   repeat(None, times = 5)
>> But that doesn't work either.
> 
> The code and/or doc is wrong, you have to use a positional arg
> and not a named one.  repeat(None, 5) does the right thing.

This is an issue in most Python documentation: you're not told
if the described function is implemented in C, and if it is
keyword arg-enabled. The arguments must be given names though,
to be able to document them.

Georg



More information about the Python-list mailing list