title: Python: How to use write/export to file in a different function?
body: <p>I'm trying to write a export to file function in Python. Here's a snippet:</p>
  
  <pre><code>#!/usr/bin/env python
  def function_1(x):
      for i in range(len(x)):
          ip = packet[i]
          mac = mac[i]
          print '{}, {}'.format(ip, mac)
  
  def export()
      f=open("data.txt", "w")
      f.write() #f.write(function_1(x))??
      f.close()
  
  if __name__ == "__main__":
      function_1(10)
      export()
  </code></pre>
  
  <p>I can do write to a file by putting it in the same function as function_1, but how would I do it in another function? Do I need to return?</p>