Yet Python doesn't. What possible benefits does this have for the Python language?
I'm not sure that Python specifically doesn't have them because of any concrete advantages to not having them. That is, there may be such advantages (one is discussed in mousetail's answer), but I don't think these advantages are what motivated Python's design decision in this case.
I suspect the main reason Python doesn't have them is simply because constants aren't needed to do anything new; any program which uses constants can be written without them, and will have the same behaviour (barring pathological cases where a program intentionally tries to assign to a constant and then catch the exception at runtime). Like access modifiers and type annotations, they can be used to check the correctness of a program but they don't change the program's behaviour, so many dynamic languages including Python and its contemporaries either don't have them, or added them significantly later (like
This is similar to the principle that "we're all consenting adults", which is a part of Python's design philosophy: the language itself doesn't need to stop you from doing things that you don't want to do. This principle can certainly be criticised, and many other languages don't adopt it, but for better or worse it is something that Python's design is based on.
A major benefit of this system is you can modify the behavior of any code, even code inside third party modules or constants there in. This functionally is used extensively for things like unit testing when you may want to isolate some functionality but control the rest. Everything being mutable allows you to do that
If Python added constant variables, it would mean some things would not be patch-able like is conventional in Python, removing a major benefit from Python.
Similar to how private variables are marked with
_ in Python, constants are marked with ALL_CAPS. It's up to the programmer to choose to actually not modify them or not.
const was introduced.