how to read serial stream of data [newbie]

Peter Otten __peter__ at web.de
Tue Feb 7 09:02:33 EST 2012


Antti J Ylikoski wrote:

> On 7.2.2012 14:13, Jean Dupont wrote:
>> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,
>> rtscts=0, dsrdtr=0, timeout=15)
> 
> In Python, if you want to continue the source line into the next text
> line, you must end the line to be continued with a backslash '\'.
> 
> So you should write:
> 
> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, \
> rtscts=0, dsrdtr=0, timeout=15)
> 
> and analogously.
> 
> Hope that this will help.  Andy.

This is wrong. A line with an open parenthesis is continued automatically:

>>> zip("abc",
... "def")
[('a', 'd'), ('b', 'e'), ('c', 'f')]
>>> ("abc"
... "def")
'abcdef'
>>> 1 + 2 + (
... 3)
6





More information about the Python-list mailing list