Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19959

Re: how to read serial stream of data [newbie]

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <modelnine@modelnine.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'python,': 0.01; 'python': 0.08; '"hello': 0.09; 'backslash': 0.09; 'brackets': 0.09; 'of)': 0.09; 'antti': 0.16; 'brackets.': 0.16; 'received:10.2': 0.16; 'wrote:': 0.18; 'header:In-Reply-To:1': 0.22; 'command': 0.24; 'fine': 0.24; 'subject:data': 0.25; 'putting': 0.28; 'true,': 0.29; 'skip:b 20': 0.29; 'jean': 0.30; 'equivalent': 0.31; '---': 0.31; 'source': 0.32; 'certainly': 0.32; 'does': 0.32; 'there': 0.33; 'this.': 0.33; 'header:User-Agent:1': 0.33; 'rather': 0.34; 'to:addr:python-list': 0.35; 'subject:]': 0.36; 'received:org': 0.36; 'but': 0.37; 'open': 0.38; 'recommended': 0.39; 'subject:how': 0.39; 'to:addr:python.org': 0.40; 'content.': 0.71; 'continued': 0.80; '_required_': 0.84; 'so:': 0.84; 'subject:read': 0.84; 'subject:stream': 0.84; 'absolutely': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=simple/simple; d=modelnine.org; s=modelnine1012; t=1328623482; bh=N0xqhwuCHnoD+DVdG+y0LeTyfoMQdrTejWX9PlfLrb8=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=g3Z8gkFEx6e/bQFDoTrk2Ct3WBx5g0U4zUf7eHk66ijHLqqGHU0nVqvq1iTNCMkqZ U6eCcPwawXC/EIqamMV2HpdzdnnuwL/yEJxgJNP0sbQiPE8TL0dJv5Qj65ZxhV/jRo at/oZ06T9XEYcwkCVDHqLJVq01BFJP1zv/8iKMLE=
Date Tue, 07 Feb 2012 15:04:39 +0100
From Heiko Wundram <modelnine@modelnine.org>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120202 Thunderbird/11.0
MIME-Version 1.0
To python-list@python.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>
In-Reply-To <sY9Yq.12835$I33.11565@uutiset.elisa.fi>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5501.1328623489.27778.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328623489 news.xs4all.nl 6988 [2001:888:2000:d::a6]:36424
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19959

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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