Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19959
| Date | 2012-02-07 15:04 +0100 |
|---|---|
| From | Heiko Wundram <modelnine@modelnine.org> |
| Subject | Re: how to read serial stream of data [newbie] |
| References | <e84f3af4-da6d-4ae9-8974-54354ec16307@b18g2000vbz.googlegroups.com> <roy-5854D8.00073507022012@news.panix.com> <cd2a40a2-5f6f-461c-9d02-f2e9e8732e6f@l14g2000vbe.googlegroups.com> <sY9Yq.12835$I33.11565@uutiset.elisa.fi> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5501.1328623489.27778.python-list@python.org> (permalink) |
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
backeted content.
So:
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.
So:
x = "hello" \
" test"
is equivalent to:
x = ("hello"
" test")
in assigning:
x = "hello test"
--
--- Heiko.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to read serial stream of data [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-06 13:40 -0800
Re: how to read serial stream of data [newbie] Roy Smith <roy@panix.com> - 2012-02-07 00:07 -0500
Re: how to read serial stream of data [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-07 04:13 -0800
Re: how to read serial stream of data [newbie] Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-07 15:48 +0200
Re: how to read serial stream of data [newbie] Peter Otten <__peter__@web.de> - 2012-02-07 15:02 +0100
Re: how to read serial stream of data [newbie] Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-07 19:44 +0200
Re: how to read serial stream of data [newbie] Heiko Wundram <modelnine@modelnine.org> - 2012-02-07 15:04 +0100
Re: how to read serial stream of data [newbie] Jean Dupont <jeandupont115@gmail.com> - 2012-02-07 06:46 -0800
Re: how to read serial stream of data [newbie] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-02-07 12:44 -0500
csiph-web