Basic doubt on compiler

if python code dosnt needs a compiler then how the code is compiled?

Hey Roshan, generally a programming languages use either compiler or interpreter or in some cases both. So python is the language which uses interpreter. In interpreter the source code is read line by line and executed and if in any line you will get any error it will stop there and notify you about that. Whereas, in case of compiler it first of all reads the whole source code and then try to figure it out whether it is correct or not, so it lists all the errors in one go.
So python is the language which uses interpreter and that’s why in this we have the functionality to get the line in which we get the error on the spot and previous of that line code is executed perfectly.
And languages such as C++ or java uses compiler so they get compiled first, the whole source code and then detects the error if any.
So I hope my explanation is clear to you. Incase there is still some confusion, you can ask me I will help you out.
And if it is clear pls mark it as resolve and provide the rating/feedback so that we can improve ourselves.
Thanks :slight_smile:
Happy Coding !!

i get you but i guess in case of java its both compiler and interpreter language.javac converts .java files into class files.these files contains a byte code and jvm interprets this byte code for execution. for c and c++ i agree with your point. also there is a work JIT in java for which i am confused now.

No no no, there isn’t anything like confusion. Yes, you are right if we use JIT for java then it uses both compilers as well as an interpreter but in a case when we don’t use JIT then it is considered as a compiler language that’s why I have written ( either compiler or interpreter or in some cases both ) this in the first line of my previous comment. Here I was talking about JIT compiler when I used in some cases. The main point is that interpreter reads the source code line by line and executes it and that is the case for python that doesn’t use compiler.