I’m currently undergoing a profound revision (read “cleanup”) of my .vimrc and I recently had to choose a decent plug-in to comment python code.
the best so far is EnhancedCommentify. it’s highly configurable, powerful and it supports a different number of languages (not only python).
the only one thing that wasn’t easy to setup if the behaviour described here: being able to comment a block, respecting the indent, in both visual and normal mode.
a clean solution, without the need to define any function is to stick these lines into your .vimrc:
vmap ,c (Plug)VisualComment
vmap ,d (Plug)VisualDeComment
vmap ,g (Plug)VisualTraditional
vmap ,f (Plug)VisualFirstLine
nmap ,c (Plug)Comment
nmap ,d (Plug)DeComment
nmap ,g (Plug)Traditional
nmap ,f (Plug)FirstLine
(but remember to change “(” to “<” and “)” to “>” — wordpress is strict about “<” and “>”…)