title: global name 'wd' is not defined in Python
body: <p>I have two scripts. One is funcLib.py, where I defines all the reusable functions, its like :</p>
  
  <pre><code>import os
  from selenium import webdriver
  from selenium.webdriver.firefox.webdriver import WebDriver
  from selenium.webdriver.common.action_chains import ActionChains
  import time
  
  global wd 
  
  
  def deviceSelection():
      desired_caps = {}
      desired_caps['appium-version'] = '1.0'
      desired_caps['platformName'] = 'iOS'
      desired_caps['platformVersion'] = '8.2'
      desired_caps['deviceName'] = 'iPhone 6'
      desired_caps['app'] = os.path.abspath('/Users/admin/Library/Developer/Xcode/DerivedData/testapp-sdsdsdfsdf/Build/Products/Debug-iphonesimulator/testApp.app')  
      wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps)
      wd.implicitly_wait(60)
      return wd
  
  def fnaccepttermsandconditions():
      time.sleep(5)    
      wd.find_element_by_name("Accept").click()
      time.sleep(5)
  </code></pre>
  
  <p>Here I define all the functions for my automation. Another file is my scripts file, where I call these functions to use in my automation. its called testfile.py</p>
  
  <pre><code>import os
  from selenium import webdriver
  from selenium.webdriver.firefox.webdriver import WebDriver
  from selenium.webdriver.common.action_chains import ActionChains
  import datetime
  import time
  import sys
  sys.path.append('/Users/Desktop/iOS/Global Scripts/')
  from funcLib import *
  
  
  wd = deviceSelection();   
  
  def main():
     signin();  
  
  
  def signin(): 
  
      try:
          time.sleep(5) 
          fnaccepttermsandconditions()
          time.sleep(5)       
  
  main()
  </code></pre>
  
  <p>Now when I execute testfile.py, It tries to call the function <code>fnaccepttermsandconditions()</code> and gets failed with an error message - <code>global name 'wd' is not defined</code> I am not sure where I am doing wrong anf I tried my level best also.</p>
  
  <p>Actually going forward I will have many functions in funcLib.py which has to call "<strong>wd</strong>". So in that case how I need to declare wd. Please help</p>