I want variables to be constant as "final" or "const" in other programming languages such as C ++ or java but not found in python.
I want variables to be constant as "final" or "const" in other programming languages such as C ++ or java but not found in python.
There are no constants in Python. They are simply defined with a name in uppercase: CONSTANTE_BLA = 10
.
That's because C ++ and Python (for example) belong to two different kinds of languages.
One is static typing and another dynamic.
In a static typing language, the verifier is able to infer the type of each expression and check whether it satisfies the statement during the compilation phase.
In a dynamic typing language, the type information of the expression is not defined until run time.
' const ' is a modifier. Restrict access to a variable when modifying it. It would be a bit inefficient to check such a restriction at runtime in a dynamic typing language.