Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python constant

class CONST(object):
    __slots__ = ()
    FOO = 1234


CONST = CONST()

print(CONST.FOO)  # 1234

CONST.FOO = 4321  # AttributeError: 'CONST' object attribute 'FOO' is read-only
CONST.BAR = 5678  # AttributeError: 'CONST' object has no attribute 'BAR'
 
PREVIOUS NEXT
Tagged: #python #constant
ADD COMMENT
Topic
Name
3+7 =