I couldn\'t find documentation on an equivalent of Java\'s final
in Python, is there such a thing?
I\'m creating a snapshot of an object (used for restorati
As of 2019 and PEP 591, Python has a Final
type. It won't be available in the standard library until the release of Python 3.8, but until then you can use it via the typing-extensions library. It won't work as final
works in Java though as Python is still a dynamically typed language. But if you use it together with a static type checker like mypy it will give you very similar benefits.
There is also a final
decorator that can be applied to mark class methods as final and preventing from being overridden. Again this is only checked at "compile-time", so you'd need to include a static type checker in your workflow.