The dictionary entries would need to be prefixed with '= #' regardless: def namedict(): namedcolors = {'maroon' : '= #262626', 'green' : '= #4b4b4b', # etc.