1You can't define a constant in Python unlike in other language, hence you can
2just make the variable all CAPS and add a comment using '#' saying that this is
3a constant variable.
1class CONST(object):
2 __slots__ = ()
3 FOO = 1234
4
5
6CONST = CONST()
7
8print(CONST.FOO) # 1234
9
10CONST.FOO = 4321 # AttributeError: 'CONST' object attribute 'FOO' is read-only
11CONST.BAR = 5678 # AttributeError: 'CONST' object has no attribute 'BAR'
12
1The constant e can be used when you
2import math
3.
4The e refers to euler''s (oiler''s) constant. It is approximately 2.71828.
5print(math.e)
6#2.718281828459045
7It is very useful when you want to make logarithms, as LOG10E has some good uses.
8math.e is fixed, and thus does not change.
9