how to read serial stream of data [newbie]
modelnine at modelnine.org
Tue Feb 7 15:04:39 CET 2012
Am 07.02.2012 14:48, schrieb Antti J Ylikoski:
> 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 '\'.
Absolutely not true, and this is bad advice (stylistically).
When (any form of) brackets are open at the end of a line, Python does
not start a new command on the next line but rather continues the
ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,
rtscts=0, dsrdtr=0, timeout=15)
is perfectly fine and certainly the recommended way of putting this.
Adding the backslash-continuation is always _possible_, but only
_required_ when there are no open brackets.
x = "hello" \
is equivalent to:
x = ("hello"
x = "hello test"
More information about the Python-list