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


Groups > comp.lang.python > #31914

Re: Style help for a Smalltalk-hack

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.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.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(python': 0.05; 'binary': 0.05; 'chunk': 0.07; 'subject:help': 0.07; 'bytes,': 0.09; 'does,': 0.09; 'formatted': 0.09; 'generators': 0.09; 'read()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spec': 0.09; 'library': 0.15; '2.7.2': 0.16; 'adjacent': 0.16; 'chunk:': 0.16; 'invocations': 0.16; 'least,': 0.16; 'oct': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'stream.': 0.16; 'travis': 0.16; 'mon,': 0.16; 'byte': 0.17; 'bytes': 0.17; 'detect': 0.17; 'code,': 0.18; 'module': 0.19; 'file.': 0.20; 'interpret': 0.22; 'split': 0.23; 'looks': 0.26; 'fit': 0.26; 'values': 0.26; 'bugs': 0.27; 'module.': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; '-0700,': 0.29; 'signatures': 0.29; 'styles': 0.29; 'source': 0.29; "i'm": 0.29; 'that.': 0.30; 'code': 0.31; 'file': 0.32; 'like:': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; "can't": 0.34; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; '(i.e.': 0.36; 'charset:us- ascii': 0.36; 'does': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'end': 0.40; 'your': 0.60; 'first': 0.61; 'chance': 0.61; 'different': 0.63; 'more': 0.63; 'other.': 0.64; 'sit': 0.65; 'comparable': 0.84; 'gap': 0.84; 'dennis': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Style help for a Smalltalk-hack
Date Mon, 22 Oct 2012 21:48:40 -0400
Organization > Bestiaria Support Staff <
References <168DF25C-0C43-45F2-BEDC-17AC4210F207@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-249-28-69.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
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 <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.2647.1350956931.27098.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350956931 news.xs4all.nl 6866 [2001:888:2000:d::a6]:56183
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31914

Show key headers only | View raw


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/

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


Thread

Re: Style help for a Smalltalk-hack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-22 21:48 -0400

csiph-web