I reworked it like this:
Thanks for making functions out of it, way cleaner.
I tested it and found a problem when the compile-command is already set to e..g a first python file and you want to execute a second python file. I also moved point to the end of Buffer if we are switching to the comint buffer, so we can directly interact with the debugger. see PR #824