title: Python - multiple functions - output of one to the next
body: <p>I know this is super basic and I have been searching everywhere but I am still very confused by everything I'm seeing and am not sure the best way to do this and am having a hard time wrapping my head around it.</p>
  
  <p>I have a script where I have multiple functions. I would like the first function to pass it's output to the second, then the second pass it's output to the third, etc. Each does it's own step in an overall process to the starting dataset.</p>
  
  <p>For example, very simplified with bad names but this is to just get the basic structure:</p>
  
  <pre><code>#!/usr/bin/python
  # script called process.py
  import sys
  infile = sys.argv[1]
  
  def function_one():
      do things
      return function_one_output
  
  def function_two():
      take output from function_one, and do more things
      return function_two_output
  
  def function_three():
      take output from function_two, do more things
      return/print function_three_output
  </code></pre>
  
  <p>I want this to run as one script and print the output/write to new file or whatever which I know how to do. Just am unclear on how to pass the intermediate outputs of each function to the next etc.</p>
  
  <p>infile -> function_one -> (intermediate1) -> function_two -> (intermediate2) -> function_three -> final result/outfile</p>
  
  <p>I know I need to use return, but I am unsure how to call this at the end to get my final output</p>
  
  <p>Individually?</p>
  
  <pre><code>function_one(infile)
  function_two()
  function_three()
  </code></pre>
  
  <p>or within each other?</p>
  
  <pre><code>function_three(function_two(function_one(infile)))
  </code></pre>
  
  <p>or within the actual function?</p>
  
  <pre><code>def function_one():
      do things
      return function_one_output
  
  def function_two():
      input_for_this_function = function_one()
  
  # etc etc etc
  </code></pre>
  
  <p>Thank you friends, I am over complicating this and need a very simple way to understand it.</p>