Huh? func_defaults, default values in function calls

Fredrik Lundh effbot at telia.com
Wed Apr 12 09:48:04 EDT 2000


Mark Hathaway <hathawa2 at marshall.edu> 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?

</F>





More information about the Python-list mailing list