I use to map F9 to :pyf % to run python files from vim. But after reading this answer, which suggests
nnoremap <buffer> <F9> :exec '!python' shellescape(@%, 1)<cr>
Just wondering which approach should be preferred for running python code from vim session.