0

I was wondering if there is a way to run only the newly added portion of a python script?

Usually I add a few lines of codes in the end of my script but I have to run the whole script to reach them and see the results. It is very time consuming specially if I have many lines of codes above. Sometimes when previous results are already saved on the local hard drive by previous runs, I use triple-quoted strings not to run previous line of the script.

Is there any other method to mange this more effectively?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Arash
  • 1,360
  • 4
  • 17
  • 32
  • 4
    This looks like a question for [so] because it is pure Python rather than GIS but in IDLE you can comment out blocks of highlighted code from its menu. – PolyGeo Oct 06 '13 at 20:33
  • 3
    If you structure your code into functions, you just call the function you want to test, rather than the whole script. See also: http://gis.stackexchange.com/a/73464/753 – blah238 Oct 06 '13 at 21:43

1 Answers1

3

If you look at this Stack Overflow question, you'll see that it's not a good idea to use the triple quotes method to "pass over" your code. Just comment it out.

Instead of prepending a #, most editors offer a shortcut to double comment (##), so that way true comments about your code won't be removed when you undo the bulk comment. It's much faster to highlight the code you want and hit the shortcut.

Paul
  • 11,608
  • 1
  • 29
  • 47