"how to think like a computer scientist"

Fredrik Lundh fredrik at pythonware.com
Sun Nov 6 16:18:56 EST 2005


"john boy" wrote:

> I am using the book "how to think like a computer scientist" and
> am finding the examples are not working with Python 2.4.2...I have
> typed them exactly as they appear in the text....can someone
> relate to this?...is this typical b/c 2.4.2 is a newer version?

no.

did you read james strouds reply to your earlier post?  the behaviour
you're describing is exactly what Python's supposed to do if you type
commands into the interactive command-line prompt.

if you don't want the Python interpreter to execute each command as
you type it, you need to use a text editor (notepad, idle, ...) and save
the entire text to a file *before* you run it.

all this is described in chapter 1 of the book you're reading:

     "There are two ways to use the interpreter: command-line mode
    and script mode. In command-line mode, you type Python programs
    and the interpreter prints the result /.../

    Alternatively, you can write a program in a file and use the interpreter
    to execute the contents of the file. Such a file is called a script. /.../"

here's an IDLE tutorial that shows you how to use both the command-line
mode and and the script mode:

    http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

hope this helps!

</F>






More information about the Python-list mailing list