What is a function parameter =[] for?

Chris Angelico rosuav at gmail.com
Thu Nov 19 06:58:33 EST 2015


On Thu, Nov 19, 2015 at 10:41 PM, BartC <bc at freeuk.com> wrote:
> As I said, it's bizarre. It means that for certain types, Python doesn't
> have a default that works per call, but only a default that works once per
> program.

No, it's not "for certain types". Regardless of the type, the
expression that defines the default is evaluated at *function
definition*, not at each *function call*. (That's not the same as
"once per program", although for 99% of situations, it'll be
indistinguishable.)

ChrisA



More information about the Python-list mailing list