In your IDLE case, you run the code in the IDLE PyShell window. This runs an interactive interpreter. In interactive mode, Python immediately interprets each input line and displays the value returned by evaluating the operator you entered, plus everything written to standard output or standard error. For Python 2, range() returns a list, and as you discovered in Python 3, it returns an iterable range() object, which you can use to create a list object or use it in other places in iterative contexts. Python 3 range () is similar to Python 2 xrange () .
When you edit a file in an editor, such as Notepad, you write a script file, and when you run the file in the Python interpreter, the entire script is interpreted and run as a unit, even if it is only one line. On the screen you see only what is written to standard output (ie, " print() ") or standard error (ie error tracing); You do not see the results of the evaluation of each operator, as in interactive mode. So, in your example, when you run from a script file, if you do not print the results of the evaluation of something, you will not see it.
The Python tutorial talks about this here .
Ned deily
source share