Huh? func_defaults, default values in function calls

Fredrik Lundh effbot at
Wed Apr 12 15:48:04 CEST 2000

Mark Hathaway <hathawa2 at> wrote:
> >> As a result, if you set a mutable object (list, dictionary, etc) as a
> >> default, it'll be set when the function is defined and then if the
> >> function changes it, it'll stay changed for subsequent invokations.
> >> The function effectively has a "side-effect", of modifying it's own
> >> default!
> This way you'll never really know what the default is going to be.

uhuh?  so you mean evaluating the default value every time the
function is called would automatically make it easier to know what
the default is going to be?  what about non-trivial default values?
what about scoping?  what about side effects? what about per-
formance?  etc.

> Ha ha ha ha. that's pathetic.

really?  I'm pretty sure Guido designed things this way on purpose,
but maybe you can come up with a better way to do it?


More information about the Python-list mailing list