2 ms·
> 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
by joshuamorton 7y ago
> 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.
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.
[0]: https://mypy.readthedocs.io/en/latest/final_attrs.html https://mypy.readthedocs.io/en/latest/final_attrs.html