title: Using logic to check if a variable is set
body: <p>Sounds simple. I'm making a "game" for a Python tutorial (Python the Hard Way, ex36).</p>
  
  <p>If the player selects "ahead" while the variable theObject is not set, they are prompted to first obtain an object, then opening() is meant to run. Does not seem to work though. </p>
  
  <p>Here is ahead()</p>
  
  <pre><code># ahead
  def ahead():
      if theObject not in globals():
          print "You need an object before you can proceed."
          opening()
  
      else:
          print "You walk for a while."
          print "Eventually you find a door to exit the Labrynthe with a code above it"
          print "You must translate the code using the code translator."
          print theObject
          if theObject == "map":
              print "You gotta get the code."
              dead("You walked too far to return. You die of exhaustion")
          elif theObject == "code":
              print "You say out aloud the magic open words 'open sesame!'"
              complete()
          else:
              print "Grab the code from the left room."
              opening()
  </code></pre>
  
  <p>I tested it out by calling ahead() from within the game, hoping to be given the message "You need an object before you can proceed" and then being presented with opening().</p>
  
  <p>But I got this instead:</p>
  
  <pre><code>ex36.py:64: SyntaxWarning: name 'theObject' is assigned to before global declaration
    global theObject
  ex36.py:73: SyntaxWarning: name 'theObject' is assigned to before global declaration
    global theObject
  You're in a Labrynthe.
  There's a door on your left.
  There's a door on your right.
  Or you can go ahead.
  &gt; 
  </code></pre>
  
  <p>It appears that the message is not being printed and instead the Syntax warning is being delivered.</p>
  
  <p>Why does my code not just say "You need an object before you can proceed" as expected?</p>