My PyTexas talk, "What to Do When the Bug is in Someone Else's Code" will be streaming in 15 minutes!
I'll be in the Youtube chat answering questions and "not really a question, more of a comment"s!
Link to stream:
https://www.youtube.com/watch?v=S4TjOnkFLtI&list=PL0MRiRrXAvRgAFCdfHUcw8PNPqS7ux_BK&index=20
@jasper Some classes and objects can be made immutable (or, at least, immutable enough), but it's certainly not the default.
At the end of the day, I think the ability to monkey patch modules and classes is a net benefit. Everyone knows that it's a code smell, so it's not done widely, but the fact that you can do it allows you to avoid some other even worse patterns.
I just had a thread about this, actually: https://qoto.org/@pganssle/105107544104982635
@jasper I do think it's the sort of thing that hurts our ability to write optimizing compilers and such without modifying semantics. It's hard to do constant folding and such when the "constant" is actually an attribute on a mutable object (and may even be dynamically returned, see PEP 562: https://www.python.org/dev/peps/pep-0562/)