title: Global name is not defined
body: <p>I am trying to check for where a global file has been defined or not.</p>
  
  <pre><code>import os, sys, logging...
  
  global my_logger
  
  def init():
    if my_logger is None:
       print 'Logger needs to be initialized'
  </code></pre>
  
  <p>However, when I run this, I get the error:</p>
  
  <pre><code>NameError: global name 'my_logger' is not defined
  </code></pre>
  
  <p>Isn't there a way to check if a variable has been declared or no? Do I have to initialize global variables before I can run a check?</p>