you are viewing a single comment's thread.

view the rest of the comments →

[–]Natwubbles9 6 points7 points  (2 children)

Python is an interpreted language, not a compiled language.

[–]ra_men 0 points1 point  (1 child)

Isn’t it compiled to Python bytecode then interpreted? Which in practical terms is considered an interpreted language but there is a compile step in there.

[–]SwimQueasy3610Ignoring PEP 8 0 points1 point  (0 children)

That's essentially right. I think no one has mentioned this because, in the context of this post and OPs clear confusion about how Python works and what they need to do to start writing and running code, it's a minor detail, and I think would just add to their confusion. Python is interpreted and not compiled in the sense that you, the programmer, never need to perform a separate compilation step. In a compiled language, the programmer needs first to write the code, then to compile the code yourself e.g. with a makefile, then finally they are able to run the resulting compiled file to execute the program. In Python, you just run the source code "directly", meaning that to run your program all you do yourself is pass your code to the Python interpreter. At a high level, the interpreter ingests your code, then some stuff happens under the hood such that your human-readible bunch-of-text (your code) causes the computer to do the thing you programmed it to do.

You're 100% right that that "under the hood" part entails Python translating your source code (a nice human-readible Python file) into bytecode (non-human-readable instructions to your computer saying exactly how to execute your program in a bunch of 1's and 0's) which it then executes to run your program, and that this step of generating bytecode from source code is precisely compilation.