If you really, really, really want to have Python constants you can do something like this:
import math
class ConstantMeta(type):
def __setattr__(cls, attr, value):
raise ValueError('You are not allowed to set constants')
class Constant(object, metaclass = ConstantMeta):
two_pi = 2.0 * math.pi
print(Constant.two_pi)
Constant.two_pi = 3
Output:
6.283185307179586
Traceback (most recent call last):
File "...", line 15, in <module>
Constant.two_pi = 3
File "...", line 5, in __setattr__
raise ValueError('You are not allowed to set constants')
ValueError: You are not allowed to set constants
The metaclass catches attempts to set a class attribute and raises a ValueError.