Python's Most Famous Gotcha: The Mutable Default Argument
You鈥檙e writing a simple Python function. It takes an item and adds it to a list, which defaults to an empty list if none is provided. It seems straightforward, but then this happens: def add_to_list(item, target=[]): # 馃毃 This is the famous bug! ...


