I know that Python interpreter executes command line by line without compiling entire program at start. But however I do not understood why it catching syntax errors on next subsequent lines without executing starting lines.
For example, in script, if I write following statements:
print("I am first")
print("Second")
print(third") # Syntax error. Missed one "
This gives below output:
File "script2.py", line 3
print(third")
^
SyntaxError: EOL while scanning string literal
I was expecting output as below:
I am first
Second
File "script2.py", line 3
print(third")
^
SyntaxError: EOL while scanning string literal
I am keen to learn why the Python interpreter exhibits this behavior.