Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 24330

Kristján Valur Jónsson: Mutable default arguments are your friend.

$
0
0
In a recent comment to an elderly post of mine, I was asked about the following code: def mywrapper(func, args=(), kwargs={}): ... The commenter though that I should have made a special mention about using dict as a default argument, “because it’s such a common gotcha.” My response is twofold: This particular case is idiomatic, and widely […]

Viewing all articles
Browse latest Browse all 24330

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>