Search code examples
pythonexecuteshellexecute

How do I execute a python file beginning in a specific code line?


I have a simulation in python which I have run, but half way to the end I got an error. I have already fixed the error. Now I want to execute the same file, but beginning in the line of the error. How can I do that? Execfile, as far as I looked doesn't do that...


Solution

  • You don't.

    The easiest solution would be to comment out all the intervening lines, or put them inside an if False: block.

    You could also simply save the appropriate portion of the code into a new file and run that instead.

    Any of these operations should be trivial in most editors.