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


Groups > comp.lang.python > #75367

Re: one to many (passing variables)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'none:': 0.07; 'returned.': 0.07; 'indicates': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'mode,': 0.16; 'non-blocking': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'returned,': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'file.': 0.24; 'header:X-Complaints-To:1': 0.27; 'mode': 0.30; 'says': 0.33; 'could': 0.34; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'consistent': 0.36; 'subject:one': 0.36; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'reaching': 0.61; 'more': 0.64; 'taking': 0.65; 'receive': 0.70; 'different.': 0.84; 'pardon': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: one to many (passing variables)
Date Wed, 30 Jul 2014 13:37:25 +0200
Organization None
References <CAHXoDSB+-Vkggfd57nb9eLSK7Pb_fbuycGTJZM=+6=4VZo3F0w@mail.gmail.com> <8561innkmw.fsf@benfinney.id.au> <53D308CB.8030900@cdreimer.com> <lr68a2$i6d$1@ger.gmane.org> <53D8D693.9040505@rece.vub.ac.be>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd85ab.dip0.t-ipconnect.de
User-Agent KNode/4.11.5
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12429.1406720261.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406720261 news.xs4all.nl 2839 [2001:888:2000:d::a6]:49363
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75367

Show key headers only | View raw


Antoon Pardon wrote:

> Taking this in consideration I think the io.RawIOBase.read got it
> backwards.
> 
> The documentation says the following:
> 
> | If 0 bytes are returned, and size was not 0, this indicates end of file.
> | If the object is in non-blocking mode and no bytes are available, None
> | is returned.
> 
> But typically if you are reading in non-blocking mode, no bytes availabe
> can be treated as if you receive an empty (byte)string. While reaching the
> end of the stream is different. So it would have been more consistent if
> an empty (byte)string was return in case of no bytes availabe and None or
> io.EOF or something like that in case of end of file.
> 
> Now I have to write things as follows:
> 
> for block in iter(partial(RawStream.read, 1024), ''):
>     if block is not None:
>         for b in block
>             process(b)

or

for block in ...:
    for b in block or ():
        process(b)

> Otherwise I could write it more as follows:
> 
> for block in iter(partial(RawStream.read, 1024), io.EOF):
>     for b in block
>         process(b)
 

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: one to many (passing variables) Peter Otten <__peter__@web.de> - 2014-07-30 13:37 +0200

csiph-web