You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey man thanks for this post, I always set None for default arguments because is a good practice, but never actually understood why? Now I know what can happen if a use mutable arguments as default!
Python default arguments are evaluated only once, when the function is defined, not when its called. So if the default argument is a mutable and is mutated inside the function, it wil stay mutated when you call the function again.
Python Mutable Defaults Are The Source of All Evil - Florimond Manca
How to prevent a common Python mistake that can lead to horrible bugs and waste everyone's time.
https://florimond.dev/en/posts/2018/08/python-mutable-defaults-are-the-source-of-all-evil/
The text was updated successfully, but these errors were encountered: