How to make a "compilation" of the code in Python?

Asked

Viewed 376 times

2

Knowing that Python is an interpreted language, is there any way to compile the program in Python? By this I mean, how to check syntax errors without having to wait for such part of the program to occur for verification. Because errors are only shown in terminal or IDE at runtime.

1 answer

4


You can only generate the bytecode through the modules py_compile and compileall. To use it you need to use the option -m:

python -m py_compile arquivo.py
  • These are alternatives, not necessarily to generate the bytecode. What he wants is just to compile, and this solves.

  • yes it does, because then I can check errors before execution and that’s what I need. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.