"Least Astonishment" and the Mutable Default Argument
"Least Astonishment" and the Mutable Default Argument Question: Anyone tinkering with Python long enough has been bitten (or torn to pieces) by the following issue: def foo(a=[]): a.append(5) return a Python novices would expect this function called with no parameter to always return a list with only one element: [5]. The result is instead very …
Total answers: 34