I tried not long ago to make python text objects not long ago. Here's the result. Unfortunately the plugin it's not documented.
You can install the plugin by downloading the objects
folder in your plugins directory and then, since everything in the plugin is opt-in, add in your vimrc
something like:
aug _objects
au!
au FileType python call objects#mapl('af', 'objects#python#def')
au FileType python call objects#mapl('if', 'objects#python#def', {'inner': 1})
au FileType python call objects#mapl('ac', 'objects#python#class')
au FileType python call objects#mapl('ic', 'objects#python#class', {'inner': 1})
au FileType python call objects#mapl('asi', 'objects#python#if', {})
au FileType python call objects#mapl('isi', 'objects#python#if', {'inner': 1})
au FileType python call objects#mapl('asf', 'objects#python#for', {})
au FileType python call objects#mapl('isf', 'objects#python#for', {'inner': 1})
au FileType python call objects#mapl('ase', 'objects#python#try', {})
au FileType python call objects#mapl('ise', 'objects#python#try', {'inner': 1})
au FileType python call objects#mapl('asw', 'objects#python#with', {})
au FileType python call objects#mapl('isw', 'objects#python#with', {'inner': 1})
aug END
or better yet, put every single call
insideafter/ftplugin/python.vim
.