title: Dynamically defining variables from a dictionary
body: <p>I am trying to dynamically define variables from a dictionary in python. I need my variables to be strings, they should appear something like this: <code>lightgreen = "#2ecc71".</code> To do this I added <code>HEX_VALUE = "'" + HEX_VALUE + "'"</code> however adding this I encountered an error</p>
  
  <pre><code>&gt; Traceback (most recent call last):
  line 22, in &lt;module&gt;
      exec("%s=%s" % (COLOUR_NAME, HEX_VALUE))
    File "&lt;string&gt;", line 1
      darkblue:='#2980b9'
              ^
  SyntaxError: invalid syntax
  </code></pre>
  
  <p>As seen from above, this adds ':' to the first part of the variable, so my question is: how can I prevent this?</p>
  
  <pre><code>COLOURS = {
      "lightgreen":"'#2ecc71'",
      "darkgreen":"#27ae60",
      "lightblue":"#3498db",
      "darkblue:":"#2980b9",
      "lightpurple":"#e74c3c",
      "darkpurple":"#8e44ad",
      "lightred":"#e74c3c",
      "darkred":"#c0392b",
      "lightorange":"#e67e22",
      "darkorange":"#d35400",
      "lightyellow":"#f1c40f",
      "darkyellow":"#f39c12",
      "lightteal": "#1abc9c",
      "darkteal": "#16a085",
      "lightnavy": "#34495e",
      "darknavy": "#2c3e50"
      }
  
  for COLOUR_NAME, HEX_VALUE in COLOURS.items():
      HEX_VALUE = "'" + HEX_VALUE + "'"
      exec("%s=%s" % (COLOUR_NAME, HEX_VALUE))
  </code></pre>