McBooCzech wrote: > This (according to your suggestions) is my code which works for me > > import serial > s = serial.Serial(port=0,baudrate=4800, timeout=20) > while 1: > line = s.readline() > words = line.split(',') > if words[0]=="$GPRMC": > print words[1], words[3], words[5] > > I just wonder if there is some beter (or as you are saying "more > pythonic":) aproach how to write such a piece of code.
import csv from serial import Serial port = Serial(port=0, baudrate=4800, timeout=20) for row in csv.reader(iter(port.readline, None)): if row[0] == "$GPMRC": print row[1], row[3], row[5] -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list