title: How to get a reference to current module's attributes in Python
body: <p>What I'm trying to do would look like this in the command line:</p>
  
  <pre><code>&gt;&gt;&gt; import mymodule
  &gt;&gt;&gt; names = dir(mymodule)
  </code></pre>
  
  <p>How can I get a reference to all the names defined in <code>mymodule</code> from within <code>mymodule</code> itself?</p>
  
  <p>Something like this:</p>
  
  <pre><code># mymodule.py
  names = dir(__thismodule__)
  </code></pre>