title: How do I send a variable from one function to another function?
body: <p>Here is an example of a function that I want to be able to pass one variable to the other.</p>
  
  <pre><code>def foo(request):
      if request.method == "POST":
          unique_id = request.POST.get('per_id','')
          baz = get_object_or_404(Name, pk=unique_id)
          return render(request, 'details/guy.html', {'baz': baz})
      return render(request, 'details/person.html')
  
  def bar(request):
      if request.method == "POST":
          baz = get_object_or_404(Name, pk=unique_id)
          return render(request, 'details/guy.html', {'baz': baz})
      return render(request, 'details/guy.html')
  </code></pre>
  
  <p>The problem is this:</p>
  
  <pre><code>local variable 'unique_id' referenced before assignment
  </code></pre>
  
  <p>So, how do I get this variable to feed from the foo(request) function to the bar(request) function?</p>
  
  <p>I know I can use cPickle, but the amount of traffic this website will be getting will almost certainly cause the cPickle object to be mixed up with another person.</p>