title: How I can parallelize a 'for' loop with an external variable?
body: <p>I am having difficulties parallelizing that part of code where <code>new_text</code> is of type unicode:</p>
  
  <pre><code>for old, new in self.replacements:
      line = pywikibot.replaceExcept(
          line, old, new, self.excsInside, self.site)
  if new_text != entry.text:
      yield pywikibot.Page(self.site, entry.title)
  </code></pre>
  
  <p>The task looks to be easy with <a href="https://pythonhosted.org/joblib/parallel.html" rel="nofollow">joblib</a> or a <a href="https://docs.python.org/2/library/multiprocessing.html#module-multiprocessing.pool" rel="nofollow">process-pool</a>, but there is <code>new_text</code> which is used outside of the loop. I have no idea of the equivalent of<code>#pragama omp ordered</code>or<code>#pragma omp atomic</code>, since there is no OpenMP wrapper for <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29" rel="nofollow">Python</a>...</p>
  
  <p>How do I determine what the value of new_next is going to be in the <code>if</code> statement if it's run in parallel?</p>