See my quick python2 edit at https://gist.github.com/junkblocker/c4b7f2417e62f0893021 . It needed os.path.expanduser(...) since my editor was set to ~/bin/vim and ~ is only expanded by shell without that.
FOO=~/bin/vim export FOO env | grep FOO shows it as expanded.