Oct-21-2023, 04:56 PM
Hello, I am currently confused about the different times when errors are detected in Python...
First, for my understanding:
Python initially translates the written code into bytecode, and this time is called "compilation." Then, the code is interpreted line by line, which is the runtime. We cannot speak of a strict compilation like in Java in the case of Python. Have I understood everything correctly up to this point?
Now, for my next issue:
I don't quite understand when different errors are detected in Python.
For example, shouldn't a Syntax Error be detected during compilation? Because Python cannot translate grammatically incorrect code. However, my script states that Python recognizes Syntax Errors when the interpreter reaches the faulty line (and executes the code up to that point). Which one is correct?
As for static-semantic and dynamic-semantic errors, in my understanding, they should be detected during runtime. For instance, accessing an undefined variable does not involve a grammatical error, so the code can be translated without issues.
Thank you for any assistance!
First, for my understanding:
Python initially translates the written code into bytecode, and this time is called "compilation." Then, the code is interpreted line by line, which is the runtime. We cannot speak of a strict compilation like in Java in the case of Python. Have I understood everything correctly up to this point?
Now, for my next issue:
I don't quite understand when different errors are detected in Python.
For example, shouldn't a Syntax Error be detected during compilation? Because Python cannot translate grammatically incorrect code. However, my script states that Python recognizes Syntax Errors when the interpreter reaches the faulty line (and executes the code up to that point). Which one is correct?
As for static-semantic and dynamic-semantic errors, in my understanding, they should be detected during runtime. For instance, accessing an undefined variable does not involve a grammatical error, so the code can be translated without issues.
Thank you for any assistance!