TIL Python's default argument values are created once, not on every call
I had a function with a default argument of an empty list, and items kept piling up across calls. The default list is created once when the function is defined, so every call that relies on the default shares the same list.
The usual fix is to default to None and create the list inside the function. What other language gotchas got you early on?
Comments · 0
No replies yet — start the conversation.