Python Serial Problem

Hi, I have problem with Python and my Arduino Duemilanove. On the Arduino I'm running this:

for (i = 0; i < 8; i = i + 1) {
digitalWrite(spalte[i], HIGH);
Serial.print(digitalRead(zeile[0]));
Serial.print(digitalRead(zeile[1]));
Serial.print(digitalRead(zeile[2]));
Serial.println(digitalRead(zeile[3]));
digitalWrite(spalte[in], LOW);
dly = 1050-analogRead(poti[0]);
delay(dly);
}

Now I want do revice this with python on my computer (Windows 7).
But if I run this:

import serial
ser = serial.Serial('COM7', baudrate = 9600, timeout=3)
print ser.readline()

the for loop stops and start from the beginning. I only receive that where i=0. Sorry for english I'm German.

xbeez

Each time a serial connection to the Arduino is made, the Arduino resets.

You need to make sure your Python script only makes one connection, not a new connection each time it wants to read data.

How can I do this? I didn't find something like that here: http://pyserial.sourceforge.net

Once you open the serial connection, using serial.Serial, you need to leave it open. All the reading from the port must be done in a loop.