title: Global variables in Ironpython
body: <p>I'm having terrible trouble trying to understand ironpython scoping rules.</p>
  
  <p>With the following script:</p>
  
  <pre><code>
  global data
  // function for call xml-rpc 
  def CallListDatabases(self):
      global synC, synCtx, result, data   
          self.synCtx = synC.Current
          service = XmlRpcService("http://localhost:8000/rpc")
          req = XmlRpcRequest(service, 'vocab_list')
          req.XmlRpcCallCompleteHandler += self.req_XmlRpcCallCompleteHandler
          result = req.Execute(self)
  
  //if call xml-rpc complete then use working rpc 
  def req_XmlRpcCallCompleteHandler (self, response, userState):
      global synCtx, synC, data
          word = []
          f = response.TryCast(clr.GetClrType(Fault))
          if f != None:
              self.synCtx.Post(self.SetCallResult, f)
              if f.FaultCode == -1:
                  pass
          else:
              self.synCtx.Post(self.SetCallResult, response)
  
  // show result with rpc complete
  def SetCallResult(self, userState):
          global data, result                
          if userState.GetType() == clr.GetClrType(Fault):
              f = userState
              if f != None:
                  print str(f.FaultString)
                  return    
          response = userState
          result = response.TryCast(clr.GetClrType(Array[str]))
          data = result   //I want to use value it
  
  print "value: "+data  //show value     
  </code></pre>                             
  
  <p><strong>Problem</strong><br>
  print "value: "+data           </p>
  
  <hr>
  
  <p>value: []  &lt;&lt;&lt;======== Not value </p>