Re:WTFPython: Exploring and understanding Python through sur...
by anthony_romeo on Tuesday May 31, 2022 @10:29AM
(#31569900)
> If I'm not mistaken there's a chapter in Effective Python about this, where they recommend never using lists or dicts as Class attributes or default values for parameters and instead use factories or use None and then initialize them with default values when a new instance is created.
Ya, this is because the initialized object is stored as the default parameter, and is not initialized every time the function runs.
Ya, this is because the initialized object is stored as the default parameter, and is not initialized every time the function runs.