Why python doesn't use syntax like function(, , x) for default parameters?

Antoon Pardon apardon at forel.vub.ac.be
Fri Mar 10 08:46:58 EST 2006


Op 2006-03-10, Roy Smith schreef <roy at panix.com>:
> "Dmitry Anikin" <anikin#remove_this#@vstu.ru> wrote:
>> There are often situations when a function has independent
>> parameters, all having reasonable defaults, and I want to
>> provide just several of them. In fact, I can do it using
>> keyword parameters, but it's rather long and you have to
>> remember/lookup names of parameters.
>
> Specifying the names of the keyword parameters costs you a little typing 
> once, but saves everybody (including yourself) a lot of grief later when 
> you're trying to figure out what the heck your code does 6 months later.

Could you explain what is so hard in figuring out:

  func(,,4)

We sure don't seem to have a problem with figuring out things like

  lst[::2]


Personnaly in a situation where it is likely that the first
parameter is going to take a default and the second parameter
is going to vary a lot, I would have prefered that to be
visible in how the function is called, instead of a call
with only one argument being interpreted as being the value
for the second parameter.

More specifically I would have preferred the possibility
of range(,n) and this being equivallent to range(0,n)
instead of range(n) being equivallent to range(0,n).

-- 
Antoon Pardon



More information about the Python-list mailing list