How is python executed as its entered? Why do we have an interpreter and a compiler, can't we just have one common thing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How is python executed as its entered? Why do we have an interpreter and a compiler, can't we just have one common thing?

30th Apr 2017, 5:49 AM
Vivek Raj
Vivek Raj - avatar
6 Answers
+ 13
use pycharm
30th Apr 2017, 6:25 AM
Agus Mei
Agus Mei - avatar
+ 11
because it is developed by different mind set from different people in different background and different environment for different purpose. diversity is good think. with intepreter you debug your code directly, something that you can't do with compiler. both has advantage and disadvantage.
30th Apr 2017, 6:06 AM
Agus Mei
Agus Mei - avatar
+ 9
Python has several ways of execution. You can either apply an interactive approach and have the code executed line by line as you press Enter or build a script and run it through the interpreter. It will also go line by line but will stop on errors or after it finishes the last line. A kind of a mid-way approach is a notebook (Jupyter for example), where you can dynamically choose on-the-go how you want your code to be executed. There are also scripting windows embedded sometimes in data analysis applications (Power BI, Visual Studio) - which enable you to run Python scripts inside the app and retrieve the data for further utilization.
30th Apr 2017, 6:53 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
Python doesnt have "compiler", only "interpreter"... You're probably talking about the standalone interpreter and the command line interpreter ^^ Both are complementary, the second one allowing to quickly test some instructions, without having to saving a source file and executing it through the standalone interpreter :P
30th Apr 2017, 6:47 AM
visph
visph - avatar
+ 1
I got another question, so interpreter is useful for debugging the code directly, but let's say we are using python for data analysis or something with a lot of computation the interpreter would say there is no problem with the code even though we can get logical errors while running the code with data, so how do we avoid this ?
30th Apr 2017, 6:11 AM
Vivek Raj
Vivek Raj - avatar
+ 1
thanks Angus MEI, I'll check out pycharm!
30th Apr 2017, 6:28 AM
Vivek Raj
Vivek Raj - avatar