title: Simpler way to create dictionary of separate variables?
body: <p>I would like to be able to get the name of a variable as a string but I don't know if Python has that much introspection capabilities. Something like:</p>
  
  <pre><code>&gt;&gt;&gt; print(my_var.__name__)
  'my_var'
  </code></pre>
  
  <p>I want to do that because I have a bunch of variables I'd like to turn into a dictionary like :</p>
  
  <pre><code>bar = True
  foo = False
  &gt;&gt;&gt; my_dict = dict(bar=bar, foo=foo)
  &gt;&gt;&gt; print my_dict 
  {'foo': False, 'bar': True}
  </code></pre>
  
  <p>But I'd like something more automatic than that.</p>
  
  <p>Python have <code>locals()</code> and <code>vars()</code>, so I guess there is a way.</p>