def edit(filehandle):
    """spawns an editor returns the file as a string; by default uses emacs if
    EDITOR is not defined in the environment, expects a filehandle as returned
    by NamedTemporaryFile()"""
    editor = os.getenv('EDITOR','emacs')
    x = os.spawnlp(os.P_WAIT,editor,editor,filehandle.name)
    if x != 0:
        print "ERROR"
    return filehandle.read()
spawns an editor returns the file as a string; by default uses emacs if
    EDITOR is not defined in the environment, expects a filehandle as returned
    by NamedTemporaryFile()
recipes/Python/286238_Spawning_an_editor_from_a_script/recipe-286238.py