Hacky usage of mutable default arguments in Python
One of the most commonly known gotchas in Python is the use of mutable default arguments. Consider this simple Python function snippet: def foo(item: int, bar: list = []) -> None: bar.append(item) print( f"{bar=}" ) # Neat f-string trick btw to print both variable name and value foo(6) foo(6) foo(12) A Python newcomer might expect the output to be: bar = [6] bar = [6] bar = [12] Instead you would get: ...