title: Global variable is None instead of instance - Python
body: <p>I'm dealing with global variables in Python. The code should work fine, but there is a problem. I have to use global variable for instance of class <code>Back</code>. When I run the application it says that back is None which should be not true because the second line in <code>setup()</code> function - <code>'back = Back.Back()'</code></p>
  
  <pre><code># -*- coding: utf-8 -*-
  from flask import Flask
  from flask import request
  from flask import render_template
  
  
  import Search
  import Back
  
  app = Flask(__name__)
  global back
  back = None
  
  @app.route('/')
  def my_form():
      return render_template('my-form.html')
  
  def setup():
      global back
      back = Back.Back()
  
  def is_ascii(s):
      return all(ord(c) &lt; 128 for c in s)  
  
  @app.route('/', methods=['POST'])
  def search():
      from time import time
  
      pattern = request.form['text']
  
      startTime = time()
  
      pattern=pattern.lower()
  
      arr = []
  
      if len(pattern)&lt;1:
          arr.append('Incorrect input')
  
          currentTime = time()-startTime
  
          return render_template('my-form.html', arr=arr, time=currentTime)
  
  
      arr = []
  
      search = Search.Search(pattern,back)
      results =  search.getResults()
  
      ..................
  
      return render_template('my-form.html', arr=arr, time=currentTime, pattern=pattern)
  
  
  app.debug=True
  if __name__ == '__main__':
      setup()
      app.run()
  </code></pre>
  
  <p>Why is the back variable None instead of instance of Back class? Thanks</p>