McBooCzech enlightened us with: > 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.
You could use regular expressions instead. And to make it even more pythonic, replace the "while" and the "line = s.readline()" with "for line in s:" Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list