title: local variable referenced before assignment for decorator
body: <p>I'm using decorator with the functional syntax as it's described <a href="http://www.python.org/dev/peps/pep-0318/#current-syntax" rel="nofollow">here</a>.</p>
  
  <p>I loop over a list of dict. In this loop I wrap a generic function with a decorator taking a parameter. Then i call the wrapped function with the current dict as parameters.</p>
  
  <p>My problem is that i get an <code>local variable 'generic_evaluator' referenced before assignment</code> error.</p>
  
  <p>Here is my code:</p>
  
  <p><strong>The concerned decorator:</strong></p>
  
  <pre><code>def log(logfile_name):
      def inner_log(func):
          def wrapped(*args, **kwargs):
              import os
              ret = func()
              # business code...
          return wraps(func)(wrapped)
      return inner_log
  </code></pre>
  
  <p>And here the place where I wrap <code>generic_evaluator</code> function with the <code>log</code> decorator.</p>
  
  <pre><code>for evaluation in generic_evaluations:
      generic_evaluator = log(evaluation['suffix'])(generic_evaluator)
      generic_evaluator(evaluation['suffix'], evaluation['id'])
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>It'll be probably more clear with this piece of code in addition:</p>
  
  <pre><code>@tictoc
  def generic_evaluator(suffix_url, id):
      xml = etree.parse(get_resource(base_url + "/" + suffix_url + "/" + str(id)))
      links = fetch_urls_from_xml(xml)
      return links
  </code></pre>