Message389291
This is normal, expected behaviour and has nothing to do with defaultdicts specifically. Any mutable object would behave the same way.
Function default parameters are evaluated only once, when the function is defined. They are not re-evaluated on each call.
The standard pattern used for re-evaluating the default is:
def function(arg=None):
if arg is None:
arg = defaultdict(list)
... |
|
Date |
User |
Action |
Args |
2021-03-22 09:56:12 | steven.daprano | set | recipients:
+ steven.daprano, TenzinCHW |
2021-03-22 09:56:12 | steven.daprano | set | messageid: <1616406972.0.0.349963061793.issue43589@roundup.psfhosted.org> |
2021-03-22 09:56:11 | steven.daprano | link | issue43589 messages |
2021-03-22 09:56:11 | steven.daprano | create | |
|