I'm going crazy about a simple Python question: I want to call a function that uses raw_input () and input () and somehow supply them with a string in my program. I searched and found that the subprocess can change stdin and stdout to PIPE; however, I cannot use a subprocess to call a function. Here is an example:
def test(): a = raw_input("Type something: ") return a if __name__=='__main__': string = "Hello World"
Of course, this is much simpler than what I'm trying to accomplish, but the basic idea is very similar.
Thank you so much!
python
dangmai
source share