I have tried:
$ grep -Po "def[[:space:]]+\K(.*)\(" code.py
The output should be a list of function names.
I think it should be correct, but it's only capturing one extra bracket. I would like to get rid off it in the expression (not postprocessing). Please, explain the syntax, you will use.
grep -Po 'def[[:space:]]+\K[^(]+' code.pyis what you neednameor the entire definitionname(args)?astmodule might be a better bet for what you're trying to do.