What is interpreter in python?
Any language is converted into machine language through translator software. There are two types of translator software:-
- Compiler
- Interpreter
Python uses an interpreter. Python is an interpreted language, not a compiled language. This means that the python installation interprets and executes the code line by line at a time. It makes python an easy-to-debug language and thus suitable for beginners to advanced users.
Since an interpreter is also a translator software like compiler, its role is to convert the source code into machine intelligible code. Though its purpose is the same as compiler, its working is very different from a compiler.
Unlike the compiler (which works with the whole program at all steps), the interpreter focuses on one line of code or one unit of code at a time. The interpreter analyses one line of code, converts into object code, adds in required libraries, if any and runs it. The first line of code is executed, even before the second line code is converted to object code. This way interpreter proceeds with each line of code.
Only once the interpreter finishes running one line of code or a section of code successfully will it actually move onto the next line.
Requires less memory during interpretation as interprets single instruction.
Interpreter displays the error of single instruction it is interpreting. Thus, errors also appear in one line at a time.
This is all about interpreter in python.