1

I would like create few constants which should be immutable like int in a separate file which can be import using a class.

I tried to create class but it's not working for me.

class test_const:
    const1 = [5, 6, 7]
    const2 = 8

>>> test_const.const1
[5, 6, 7]
>>> test_const.const1 = "overwrite"
>>> test_const.const1
"overwrite"

When we overwrite the constant it should through error like X SyntaxError: can't assign to const1 ( because const1 is immutable)

Rohit Agrawal
  • 31
  • 1
  • 1
  • 2

0 Answers0