functions, list, default parameters

Mark Wooding mdw at distorted.org.uk
Thu Nov 4 18:34:07 EDT 2010


Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> writes:

> In message <20101021235138.609fe668 at geekmail.INVALID>, Andreas
> Waldenburger wrote:
> > While not very commonly needed, why should a shared default argument be
> > forbidden?
>
> Because it’s safer to disallow it than to allow it.

Scissors with rounded ends are safer than scissors without.  Chopsticks
and plastic sporks are safer than metal cutlery.  We have sharp things
because they're /useful/.  Similarly, having mutable objects as argument
defaults can be useful.

(Based on experience with other languages, I suspect that evaluating the
default expression afresh for each call where it's needed would be more
useful; but it's way too late to change that now.)

-- [mdw]



More information about the Python-list mailing list