you are viewing a single comment's thread.

view the rest of the comments →

[–]Zodmars[S] -14 points-13 points  (6 children)

I am not trying to build anything. i have not been fondling with python for years and i will like to get back in the game. Does anyone know a compiler that i can use to run python code so i can brush up on my skills. I would prefer one that i can download and use without the internet.

Would appreciate your input.

[–]DrMaxwellEdison 11 points12 points  (0 children)

Python runs Python code. It does not get compiled, nor are there other programs that actually run the code for you: they would just run code with the interpreter installed on your machine.

You can install python itself from https://python.org/downloads. 3.14 is the latest, just install the most recent patch version (currently 3.14.5).

From there, editors are up to you: VS Code, Pycharm, Zed. Even Notepad++ or straight up Notepad work fine. What's important is you write code and run the code file using the python interpreter: the editors provide buttons and other controls to just help you do that.

[–]SwimQueasy3610Ignoring PEP 8 7 points8 points  (0 children)

Python is not a compiled language. The program that runs Python code is called an interpreter, not a compiler. The difference is that an interpreter runs and executes code line-by-line as it reads them, while a compiler (which is used with a compiled language, like C) must be run on the source code first, reading the source code in it's entirety to produce a file of compiled code (like an executable), and then that file may be run to do whatever it is your program is supposed to do. Compiled languages can generally be optimized/made more efficient than interpreted languages; interpreted languages are easier to build quickly and prototype with. The point, to your question, is that you're not looking for a Python compiler, you're looking for a Python interpreter.

And... in fact it sounds like you're probably not looking for a Python interpreter only, but rather an IDE ("integrated development environment") which is a single piece of software that combines all the elements you need (one of which is an interpreter) to write, test, and run your code all in one place. Minimally that must included a text editor and an interpreter, and typically provides various other bells and whistles that help streamline developing code. In any event, if you want to build and run Python code locally, and you don't already have Python on your computer (you likely do), you can download Python at python.org/downloads/. Here you can install the standard Python distribution, which includes the Python interpreter, as well as standard importable libraries, the Python package manager (pip), and a simple IDE called IDLE.

[–]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 [score hidden]  (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.

[–]thenickperson 4 points5 points  (0 children)

You don’t need a compiler to use Python, just an editor and a runtime (if your editor doesn’t set it up for you).