How to use a string as stdin
<p>I have been going crazy over a seemingly easy question with Python: I want to call a function that uses raw_input() and input(), and somehow supply those with a string in my program. I've been searching and found that subprocess can change stdin and stdout to PIPE; however, I can't use subprocess to call a function. Here's an example:</p>

<pre><code>def test():
    a = raw_input("Type something: ")
    return a

if __name__=='__main__':
    string = "Hello World" # I want to a in test() to be Hello World
    returnValue = test()
</code></pre>

<p>Of course this is much simpler than what I'm trying to accomplish, but the basic idea is very similar.</p>

<p>Thanks a lot!</p>
