On 2005-08-24, Sybren Stuvel <[EMAIL PROTECTED]> wrote: >> 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.
"There is a programmer who has a problem to solve. He decides to use regular expressions. Now he has two problems." > And to make it even more pythonic, replace the "while" and the > "line = s.readline()" with "for line in s:" Serial port objects aren't iterable. -- Grant Edwards grante Yow! I was making donuts at and now I'm on a bus! visi.com -- http://mail.python.org/mailman/listinfo/python-list