A constant, in any programming language, is an identifier whose value is not meant to be changed once it is set. It does not matter when this value is learned so long as the constant can not be accessed with anything but this one value.
If you wish to distinguish between types of constants based on when their value is known the terms are:
- Compile-time (statically-valued) constants
- Run-time (dynamically-valued) constants
Values that are defined at compile time directly in the source are called literals. 2 is a literal.
How well constants are protected from accidental change varies from language to language. A common naming convention to signal the intent not to change the value to capitalize the name.
Python has a tradition of using naming conventions rather than keywords to signal what keywords would otherwise enforce. There is no const keyword just like there is no private keyword. Instead they use CAPITALS_SEPERATED_BY_UNDERSCORES and __PRIVATES_PRECEDED_BY_UNDERSCORES.
While Python has no const keyword to protect a constant from change there are ways to simulate the protection with getters and such. If you simply don't trust your fellow programmer to respect what you signal with the naming convention. Much like in Java, where the determined can defeat these protections using reflection, understand that nothing will perfectly protect this value. Be sure the naming convention is really insufficient for your needs before constructing your own protections.