grep for all .py files containing a word

Shell
grep -rnw '/path/to/somewhere/' -e 'pattern'
Source

Also in Shell: