You can put if
/endif
tests in your mappings by way of :execute
but that's a bit messy.
What you should do instead is define your mappings in filetype-specific autocmd
s (see :h autocmd
):
autocmd FileType python nnoremap this that
or, better, define them in ~/.vim/after/ftplugin/python.vim
(and another file for coffeescript and so on):
nnoremap <buffer> this that