I have a big .py file, and I want Python to ignore everything after, say, 15th line…
Something like this:
import this
import that
def foo():
...
def foobar():
...
MANUAL_EOF_HERE_SO_DEAR_PYTHON_PLEASE_IGNORE_THE_REST_OF_THIS_FILE
def bar():
....
Is there such a thing? Using python 2.7.
Three choices:
Comment out every line after a certain point by inserting a # at the start of it (which should be easy in your text editor)
Put the entire block of code into a block quote by putting
"""at the start and end of it (this won’t work if there are triple-quoted regions within the code) ETA: Better yet, use'''(triple single quotes)Use
sys.exit()to stop the program at some point (having doneimport sysearlier). Note that this will stop the code from executing, but will not stop it from being interpreted by Python. Thus, any syntax errors below that line could still cause the program to break.