Python is the verification method that compiles and runs

  • 2020-04-02 14:30:46
  • OfStack

Although Python is described as an interpreted language, Python source programs are actually compiled before they can be run.

Like the Java language, the Python source program is compiled to get bytecode, which is left to the Python virtual machine to run.

We can verify this by:


#!/usr/bin/python
 
print "position1"
1_syntax_error_identifier
print "position2"

Save it as program.py, and then run it in a shell window:

root@dell:~$ ./program.py
  File "./program.py", line 4
    1_syntax_error_identifier
                            ^
SyntaxError: invalid syntax
root@dell:~$ <br>

From here, you can see that if Python were a pure interpretation run, it would output position1.
If you're compiling and running, you should first find syntax errors in the source code, which is exactly what this example shows.


Related articles: