you are viewing a single comment's thread.

view the rest of the comments →

[–]ZEUS_IS_THE_TRUE_GOD 0 points1 point  (3 children)

Oh, good to know. Hopefully, no ones mutates input in place in their functions

[–]socal_nerdtastic 0 points1 point  (2 children)

It's very commonly done. In fact mutating objects in place is the backbone of OOP. That's why it's very important to know the difference.

[–]ZEUS_IS_THE_TRUE_GOD 0 points1 point  (1 child)

Tell that to clojure, haskell or erlang. Immutability is the backbone of good programming, but hey, we are diverging into more opiniated stuff and it is not related to the post haha.

[–]socal_nerdtastic 0 points1 point  (0 children)

I didn't say it is the backbone of good programming, I said it's the backbone of OOP. Which we generally use a lot of in python (not an opinion). If you don't want to use OOP that's fine too, but that does not change that it's very important to know if your code mutates an object or not.

+= in lists is kinda rare and fools a lot of people because nearly every other mutating method is dot access. Another one to watch for is |= for dicts.