title: Multiprocessing & Pool in __main__ - how to get the output outside the __main__?
body: <p>Based on this answer (<a href="https://stackoverflow.com/a/20192251/9024698">https://stackoverflow.com/a/20192251/9024698</a>), I have to do this:</p>
  
  <pre><code>from multiprocessing import Pool
  
  def process_image(name):
      sci=fits.open('{}.fits'.format(name))
      &lt;process&gt;
  
  if __name__ == '__main__':
      pool = Pool()                         # Create a multiprocessing Pool
      pool.map(process_image, data_inputs)  # process data_inputs iterable with pool
  </code></pre>
  
  <p>to multi-process a <code>for</code> loop.</p>
  
  <p>However, I am wondering, how can I get the output of this and further process if I want?</p>
  
  <p>It must be like that:</p>
  
  <pre><code>if __name__ == '__main__':
      pool = Pool()                         # Create a multiprocessing Pool
      output = pool.map(process_image, data_inputs)  # process data_inputs iterable with pool
      # further processing
  </code></pre>
  
  <p>But then this means that I have to put all the rest of my code in <code>__main__</code> unless I write everything in functions which are called by <code>__main__</code>?</p>
  
  <p>The notion of <code>__main__</code> has been always pretty confusing to me.</p>