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


Groups > comp.lang.python > #75367 > unrolled thread

Re: one to many (passing variables)

Started byPeter Otten <__peter__@web.de>
First post2014-07-30 13:37 +0200
Last post2014-07-30 13:37 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#75367 — Re: one to many (passing variables)

FromPeter Otten <__peter__@web.de>
Date2014-07-30 13:37 +0200
SubjectRe: one to many (passing variables)
Message-ID<mailman.12429.1406720261.18130.python-list@python.org>
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)
 

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web