[Tutor] Running range scripts in IDE
Kent Johnson
kent37 at tds.net
Fri Jun 10 17:20:34 CEST 2005
typetext wrote:
> I am using I. Langingham's Teach yourself Python in 24 hours, and up
> to chapter 4 I had no problem. I have installed the IDE , and as far
> as I know, all the other programs associated with Python, and had been
> batting along with no problem, using simple scripts such as "hello
> world" in notepad or notetab (another text processor) until I hit the
> range function. Then I tried to save and run a script with the
> following content.
>
> range(10)
>
> which returns the expected output when I type the command directly on
> the prompt line of IDE, but just returns either nothing or the words
> range(10) when I use the run command and try to do it as script, saved
> as r10.py or a number of other names ending with the extention .py. I
> realize this might be an elementary question, but I am stuck. What am
> I doing wrong? I am using Windows XP.
When you type an expression to the interactive interpreter, it evaluates the expression and prints the result, so you get
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
This is called the read-eval-print loop or REPL; it is a feature of the interpreter.
In a program, you have to make the print explicit:
print range(10)
Kent
More information about the Tutor
mailing list