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

Antoon Pardon apardon at forel.vub.ac.be
Fri Oct 6 06:19:20 EDT 2006


On 2006-10-06, hanumizzle <hanumizzle at gmail.com> wrote:
> On 6 Oct 2006 09:21:11 GMT, Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>> On 2006-10-06, Fredrik Lundh <fredrik at pythonware.com> wrote:
>> > Antoon Pardon wrote:
>> >
>> >> Is this general rules documeted somewhere? My impression is that readers
>> >> of the documentation will treat arguments as keyword arguments unless
>> >> this is explicitly contradicted.
>> >
>> > Sorry, I missed that this was comp.lang.python.alternate.reality.  My
>> > mistake.
>> >
>>
>> A personal attack won't make my argument go away. It also doesn't
>> answer my question.
>
> Not sure exactly what is going on / being argued about in this thread but HTH :?
>
> http://docs.python.org/tut/node6.html
>
> This doesn't say anything positive or negative about the practice in
> question, but does point out that it is possible. I think it is a
> reasonable assumption that if it isn't necessary, most users will
> elide the keywords.

What I am argueing is that it is very natural for python programmers to
assume that keyword arguments will work if they see a signature. IMO
if a python programmer sees something like:

  abs(x)

It is very natural to envision a corresponding def statement like:

  def abs(x):

and a python function written like this will work if called as
follows:

  abs(x=5)

IMO this is a very natural thought process for a python programmer.
So a python programmer seeing the first will tend to expect that
last call to work.

Now frederic claims that the general rule is different. Now I'm
perfectly happy to accept that those who write the documentation
do so based aacording to the rule frederic stated (you can't/shouldn't
use a parameter as a keyword argument unless explictly stated in the
documentation), but that doesn't contradict that readers may have
different expectations.

-- 
Antoon Pardon



More information about the Python-list mailing list