I\'m trying to start a text editor (nano) from inside Python, have the user enter text, and then capture the text once they writeout (Control-O). I haven\'t worked with the
Control-O in Nano writes to the file being edited, i.e., not to standard output -- so, forego the attempt to capture stdout and just read the file once the user writes it out and exits Nano. E.g., on my Mac:
>>> import tempfile
>>> f = tempfile.NamedTemporaryFile(mode='w+t', delete=False)
>>> n = f.name
>>> f.close()
>>> import subprocess
>>> subprocess.call(['nano', n])
Here, I write "Hello world!" then hit control-O Return control-X , and:
0
>>> with open(n) as f: print f.read()
...
Hello world!
>>>