py-serial + CSV
sybrenUSE at YOURthirdtower.com.imagination
Wed Aug 24 09:54:41 CEST 2005
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=="$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. And to make it even more
pythonic, replace the "while" and the "line = s.readline()" with
"for line in s:"
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?
More information about the Python-list