What reserved word is there in python to make any variable constant? [duplicate]

1

I want variables to be constant as "final" or "const" in other programming languages such as C ++ or java but not found in python.

    
asked by Anthony Ramos Roncal 05.09.2017 в 03:47
source

2 answers

0

There are no constants in Python. They are simply defined with a name in uppercase: CONSTANTE_BLA = 10 .

    
answered by 05.09.2017 в 05:50
0

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.

    
answered by 05.09.2017 в 05:56