py-serial + CSV
grante at visi.com
Wed Aug 24 16:25:37 CEST 2005
On 2005-08-24, Sybren Stuvel <sybrenUSE at YOURthirdtower.com.imagination> wrote:
>> import serial
>> s = serial.Serial(port=0,baudrate=4800, timeout=20)
>> while 1:
>> line = s.readline()
>> words = line.split(',')
>> if words=="$GPRMC":
>> print words, words, words
>> 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!
More information about the Python-list