Vim indentation for specific file type extensions

I am very fond of 2 spaces for indentation in most of my files, but I want to follow the convention with using a width of 4 when coding in Python.

The easiest way I could find how was to add a line in ~/.vimrc

autocmd FileType python setlocal shiftwidth=4

In my own setup (which may not apply to you), I’ve set the global settings as such:

set shiftwidth=2
set softtabstop=2