Re:WTFPython – Understanding Python through surprising snippets
by Izkata on Monday December 23, 2019 @08:47AM
(#21863532)
The underlying feature that both rely on is that default arguments are set on function declaration instead of function call. Mutable/immutable only affects whether or not you hit the bug.
The lambda case here is more like a default argument of a constant integer (immutable) than a default that is a list, which can be altered directly by the function it's a default of.