Python Encapsulate a function to Print to a variable
<p>If I have a function that contains a lot of print statements:</p>

<p>ie.</p>

<pre><code>def funA():
  print "Hi"
  print "There"
  print "Friend"
  print "!"
</code></pre>

<p>What I want to do is something like this</p>

<pre><code>def main():
  ##funA() does not print to screen here
  a = getPrint(funA()) ##where getPrint is some made up function/object
  print a ##prints what funA would normally print at this step
</code></pre>

<p>So when funcA gets called it doesn't do any printing, instead it output to an object. I then print the object to get the result. Is there a way of doing this? I also do not want to touch the original function.</p>

<p>I hope it makes sense.</p>
