r/Python • • 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

218 comments sorted by

View all comments

Show parent comments

1

u/BeKenny Jul 22 '21

How is something built into the language a non issue? The reason people would do it this way is because they can and they didn't learn otherwise. You can make an argument for never using default arguments ever if you'd like, but no need to be condescending.

-4

u/stackered Jul 22 '21

its a non issue if you are coding to be readable and not trying to be overly pythonic, which is a thing IMO. people try way too hard to shorten their function only to create bugs and make it harder to work with for others... sometimes shortening the code does neither of these things. of course, there are lots of nuances to any programming language you'll have to learn. I'm not being condescending at all, just giving my opinions