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


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

Re: Style help for a Smalltalk-hack

Started byDennis Lee Bieber <wlfraed@ix.netcom.com>
First post2012-10-22 21:48 -0400
Last post2012-10-22 21:48 -0400
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: Style help for a Smalltalk-hack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-22 21:48 -0400

#31914 — Re: Style help for a Smalltalk-hack

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-10-22 21:48 -0400
SubjectRe: Style help for a Smalltalk-hack
Message-ID<mailman.2647.1350956931.27098.python-list@python.org>
On Mon, 22 Oct 2012 17:43:00 -0700, Travis Griggs
<travisgriggs@gmail.com> declaimed the following in
gmane.comp.python.general:

> I'm writing some code that does a structured read from formatted binary file. The code I came up with looks like:
> 
> # get the first four bytes, the first gap field
> chunk = byteStream.read(4)
> while chunk:
>     # interpret the gap bytes
	<snip> 
> I can't help but thinking that there's some better way (i.e. more pythonic) to do this that doesn't involve having to use another module (Construct) or exploring generators or something like that. What bugs me about it is that there is two different styles for reading/decoding values from the byte stream. valveCount and signatures are both paired invocations of unpack() and read(). But to detect the end of the stream (file), I have to split the read() and unpack() of the gap value across 3 different lines of the code, and they don't even sit adjacent to each other.
> 

	Is there any chance this file might fit an IFF spec? If it does, see
the "chunk" module (Python 2.7.2 library reference section 21.6)

	At the least, even if it doesn't fit the full IFF spec (no chunk
name, perhaps) you might be able to purloin the source code to create
your own comparable module.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [standalone]


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


csiph-web