title: Create list in main script, generate content in other script, return to main with content
body: <p>in my project, I want to reconcile selected data retrieved from various databases and print out differences. I</p>
  
  <ol>
  <li>create a list containing datasets to be reconciled (dataset1, dataset2, dataset3)</li>
  <li>create a dictionary of lists where I store output from each database (i.e. list_db1, list_db2, list_db3)</li>
  <li>start loop where for each dataset a call is issued to n databases (sql queries are read from external file)</li>
  <li>modify database returns (formatting but also qualitative changes)</li>
  <li>do some set operations among returned data</li>
  <li>print out differences</li>
  <li>clear lists in dictionary and go to next dataset</li>
  </ol>
  
  <p>I would like to move step 4 from main script outside, to achieve better maintainability. For dataset A, I want to modify data from database X in way x_A, from database Y in way y_A, from database Z in way z_A. For dataset B, I only want to modify data from database Z in way z_B.</p>
  
  <p>The function which modifies database return is currently part of main script and is a somewhat complex if-then statement.</p>
  
  <pre><code>def retrieve_db1(dataset):
     ...
     list_db1.append(sql_output)
     ...
  def retrieve_db2(dataset):
     ...
     list_db2.append(sql_output)
     ...
  def retrieve_db3(dataset):
     ...
     list_db3.append(sql_output)
     ...
  
  def myfunction(arg1,arg2):
       if arg1 == 'dataset1':
         if arg2 == 'list_db1':
            list_db1.append('x')
         elif arg2 == 'list_db3':
            list_db2.append('y')
         else:
            None 
  
      elif arg1 == 'dataset2':
         if arg2 == 'list_db3':
            list_db3.append('z')
         else:
            None
      ...
      return arg2
  
  datasets = ['dataset1','dataset2','dataset3']
  for d in datasets:
     mydict = {'list_db1':[],'list_db2':[],'list_db3':[]}
  
     retrieve_db1(d)
     myfunction(d,list_db1)
     retrieve_db2(d)
     myfunction(d,list_db2)
     retrieve_db3(d)       
     myfunction(d,list_db3)
  
     #... merge list_db1 and list_db2, find differences against list_db3, print out etc.
  </code></pre>
  
  <p>As you see, the function itself is a decision tree dependent on both arguments. Is it possible to maintain only the part of code with decision tree in a separate file (script)? </p>
  
  <pre><code>import other_script
  
  def my_function(arg1,arg2):
      ...
      other_script(arg1,arg2)
      ...
  </code></pre>
  
  <p>The tree is quite complex and this helps with maintenance of both scripts. I am not sure how to ensure that list created with main script is modified when running other_script, that is data is still there when I return to main.</p>