How to process syntax errors

Marko Rauhamaa marko at pacujo.net
Tue Oct 11 04:38:03 EDT 2016


Chris Angelico <rosuav at gmail.com>:

>>> > You're right, except that Python is never compiled, it was just
>>> > checked for syntax error before interpreting code.
>>>
>>> https://docs.python.org/3/library/functions.html#compile
>>>
>>> It's compiled.
>>
>> Using this function, the code is "compiled".
>> I do not think this function is often used and most python project
>> simply use the interpreter (which do a small translation into
>> byte-code to be faster and check syntax error before running
>> interpretation).
>
> When you import, the same form of compilation is done. It always
> happens. Python does not execute your raw source code - it'd be too
> inefficient.

There's no clear line between compilation and interpretation. You have
the source code and the execution semantics. All kinds of opportune
transformations can take place before the execution, after the
execution, during the execution etc as long as the correct semantics are
obeyed.


Marko



More information about the Python-list mailing list