But is there a way to force immutable variables in Python? You can easily still end up in the same situation when you typo something (easy to do when plurals are involved), and then end up reassigning something when you meant to create a new variable.
Needless to say, I was not using Pycharm for this development, nor am I likely to install an entire IDE just for a small change I'm making on a random project. It's a non-trivial burden to configure and learn an entire IDE, vs just using what I already know (which is often just emacs).
any new tool chain.
It's hard to take complaints like this seriously.
Because those IDEs those solve problems, so that you can close tickets on the project at hand, without having to port it to the best language evar.
Not always. Mypy has experimental support for `Final[T]` [0], and attrs/dataclasses support final/frozen instances, but that's opt in on a per-argument basis.
And I should add that the "right" way to do this would be to factor this out to a function:
is much clearer than either block, and avoids the possibility of the issue.