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

0

u/Caboose522 Jul 22 '21

It doesnt read well I agree, and in this case it probably wouldnt give any performance advantage. I like the concept though and I could think of other situations where this could make sense. The cool thing is if you grasp it you can use it to write more succinctly, and less code is usually a good thing.

0

u/[deleted] Jul 23 '21

[deleted]

0

u/Caboose522 Jul 23 '21

Never? Who said it was?

0

u/[deleted] Jul 23 '21

[deleted]

-1

u/Caboose522 Jul 23 '21

I think you can figure out those arent the same thing.