Python Mutable Arguments: Why Functions Change Your Lists and Dicts
Python doesn't copy a list or dictionary when you pass it into a function — it hands over the same object. This post builds the name-vs-object mental model behind that, then works through the mutable default argument trap, dictionaries, shallow copies, and two sharp gotchas on one small running example.
July 19, 2026 in Python by Mehdi Lotfinejad9 minutes