read the source of any tool ( operator )
Not all operators are written in python, and so you won't be able to get the source from them.

Fortunatelly, Blender is open source and you can look into the source code.
In case of the knife tool, you might want to check this folder:

https://git.blender.org/gitweb/gitweb.cgi/blender.git/tree/HEAD:/source/blender/editors/mesh