Best/Cleanest way to define constant lists or dictionaries [closed]

Put your constants into their own module:

# constants.py

RED = 1
BLUE = 2
GREEN = 3

Then import that module and use the constants:

import constants

print "RED is", constants.RED

The constants can be any value you like, I’ve shown integers here, but lists and dicts would work just the same.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)