196 reputation
1
bio website skanev.com
location Sofia, Bulgaria
age
visits member for 2 years, 5 months
seen Oct 4 at 14:49

Jul
19
comment Python mutable default argument: Why?
The thing about the least surprise here is this: if you have the evaluate-on-every-call semantics, you can get an error if the closure changes between two function calls (which is quite possible). This can be more surprising as opposed to knowing that it is evaluated once. Of course, one can argue that when you come from other languages, you except evaluate-on-each-call semantics and that is the surprise, but you can see how it goes both ways :)
Jul
19
awarded  Teacher
Jul
19
answered Python mutable default argument: Why?