From your comment you should be doing
pgrep donothing.py or
pgrep -x donothing.py.
pgrep -f it looks for any command which has the matching string in it's name and/or arguments. There is no pretty way of filtering out results. The solution is to match exactly what you're after, so match the process name.
pgrep by default matches just the process name. By default it will search for any process who's name contains the match string. With
-x it will search for any process who's name exactly matches the string.
pgrep is also smart enough to understand scripts. If you have a script called
foo.sh, it will show up in
/bin/sh foo.sh (or something similar). In this case
pgrep will instead compare the script name. So you can do
pgrep foo.sh or
pgrep -x foo.sh.
So in your case, you should be doing
pgrep -x donothing.py to get an exact match.
I should note that this only works if the script was launched as
/path/to/donothing.py. If you launch it as
python donothing.py it will not work.
In this case you need to use a regex like
pgrep -f '^python donothing.py'.
The problem you're encountering with
watch is quoting. running
watch pgrep -f '^python donothing.py' runs
pgrep with no arguments. The
-f '^python donothing.py' is passed as an argument to
pgrep as intended. The whole pgrep command should be quoted.
watch "pgrep -f '^python donothing.py'"
As another note. If you are going to use this for other stuff, it might safer to do
watch "pgrep -f '(^|\S+/)python donothing.py'"
This will catch the case where the process shows up as something like
/usr/bin/python instead of just