Ejemplo 1: delcare consatnt python
# You can't, just use uppercase to identify
Ejemplo 2: como definir una constante en python
You can't define a constant in Python unlike in other language, hence you can
just make the variable all CAPS and add a comment using '#' saying that this is
a constant variable.
Ejemplo 3: constante de Python
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'
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)