title: Why is globals() a function in Python?
body: <p>Python offers the function <code>globals()</code> to access a dictionary of all global variables. Why is that a function and not a variable? The following works:</p>
  
  <pre><code>g = globals()
  g["foo"] = "bar"
  print foo # Works and outputs "bar"
  </code></pre>
  
  <p>What is the rationale behind hiding globals in a function? And is it better to call it only once and store a reference somewhere or should I call it each time I need it?</p>
  
  <p>IMHO, this is not a duplicate of <a href="https://stackoverflow.com/questions/12693606">Reason for globals() in Python?</a>, because I'm not asking why <code>globals()</code> exist but rather why it must be a function (instead of a variable <code>__globals__</code>).</p>