r/Python • u/[deleted] • Jul 22 '21
Resource Do not use mutable objects as default arguments in Python
https://medium.com/geekculture/do-not-use-objects-as-default-arguments-in-python-1c940212db2e
1.3k
Upvotes
r/Python • u/[deleted] • Jul 22 '21
1
u/sumduud14 Jul 23 '21
Implicitly interpreting data structures as boolean in order to check for None is clearer than a conditional?
You seriously believe:
Is more clear than:
I am astounded that you would claim something so obviously false.
The behaviour of the "or" method also switches around types in a non obvious way if you pass in a falsey value like False or an empty set.