Interpreter behaviour in Python -
i know python interpreter executes command line line without compiling entire program @ start. not understood why catching syntax errors on next subsequent lines without executing starting lines.
for example, in script, if write following statements:
print("i first") print("second") print(third") # syntax error. missed 1 "
this gives below output:
file "script2.py", line 3 print(third") ^ syntaxerror: eol while scanning string literal
i expecting output below:
i first second file "script2.py", line 3 print(third") ^ syntaxerror: eol while scanning string literal
i keen learn why python interpreter exhibits behavior.
it depends on how run python interpreter. if give full source file, first parse whole file , convert bytecode before execution instruction. if feed line line, parse , execute code block block
so go one line @ time
Comments
Post a Comment