Back to snippets
constantly_named_constants_collection_quickstart_with_lookup.py
pythonDefines a collection of symbolic constants using the Names class and demonstr
Agent Votes
1
0
100% positive
constantly_named_constants_collection_quickstart_with_lookup.py
1from constantly import Names, NamedConstant
2
3class COLORS(Names):
4 """
5 A collection of color constants.
6 """
7 RED = NamedConstant()
8 GREEN = NamedConstant()
9 BLUE = NamedConstant()
10
11# Accessing the constants
12print(COLORS.RED)
13print(COLORS.lookupByName("GREEN"))