
May 24, 2021
10:59 a.m.
Thomas Grainger:
This is already available with typing.Final and immutable types:
from typing import Final
ham: Final = 3 ham = 4 # Error
hams: Final[Sequence[str]] = ["ham", "spam"] hams.append("meat") # Error
I'm not sure whether it's a reply to me or someone else. But anyways this is a convention. mypy will detect it. *But* I have a feeling that constants can have performance improvements though I'm not sure.