Python fundamentals (2) — saving Python programs as files

IDLE has a mode in which the user can write multiple lines of code, save them in a file, and execute them whenever he/she chooses. This is, well, pretty handy if you are programming:

Here you can see that I am in a New File (right window)- and that the executed code is running in the left window. Quirk of Python — writing 17 + 9 and 67–14 is absolutely fine; it returns no error message. However it does not display in the shell (also known as the console*) — you need to actually issue Python with a print command in order to see the results of the calculation. So Python will obediently hold onto the results of calculations — possibly storing them in variables or as arrays or something — but will steadfastly keep hold of them until you issue a display command such as print.

The New File window is where you start to really get to grips with the interpreter. An interpreter in a programming language is a facility that allows you to program, save the code, and run the code. An interpreter will work its way through the code line by line, and it will not produce any executable (.exe) object code without any prompting. For that you will need a compiler, but that is for another discussion. Either way, with the New File interpreter, you can start to get to grips with proper programming.

*Nothing to do with Xboxes or PS4s. Unlucky.

read original article here