Hey,
I need a method to get the data from an external editor.
def _get_content():
from subprocess import call
file = open(file, "w").write(some_name)
call(editor + " " + file, shell=True)
file.close()
file = open(file)
x = file.readlines()
[snip]
I personally think there should be a more elegant way. You see, I need to interact with an external editor and get the data.
Do you know any better approaches/have better ideas?
EDIT:
Marcelo brought me on the idea of using tempfile
for doing that.
Here's how I do it:
def _tempfile_write(input):
from tempfile import NamedTemporaryFile
x = NamedTemporaryFile()
x.file.write(input)
x.close()
y = open(x)
[snip]
This does the job, but also not quite satisfying. Heard something about spawning?..