Best way to split up lines - RE: About the 79 characterlinerecommendation

Hendrik van Rooyen mail at microcorp.co.za
Fri Dec 8 01:03:41 EST 2006


"John Machin" <sjmachin at lexicon.net> wrote:

8<-------------------

> >     data = struct.unpack("!H4BH20BHI", strMessage)
> >
> >     (top, ip1, ip2, ip3, ip4, messageCounter, ackRequired,
> >     dataType, utc1, utc2, utc3, utc4, utc5, utc6, utc7, utc8,
> >     utc9, utc10, utc11, utc12, st1, st2, st3, st4, st5, st6,
> >     numberOfLabels, dataWord) = data
> >
>
> Those utc1, ..., utc12 etc inspire a suggestion: a mild addition to the
> syntax to allow specifying that the following repeat count should be
> interpreted as the expected dimension of a tuple (unpack) or any
> indexable object with a __len__ method (pack):
>
> (top, ip, messageCounter, ackRequired,
> dataType, utc, st, numberOfLabels, dataWord,
> ) = struct.unpack("! H /4B H B B /12B /6B H I", strMessage)
>
> Apropos of a recent thread: I don't need pointing at the suggestion box
> and the patch submission gizmoid on Sourceforge -- I'd be happy to do a
> patch, just wondering if anybody's interested in having that, besides
> me and Pat Malone :-)

just a comment - it took me a while to figure out what you were on about.

The relationship between the sources and targets are not immediately obvious
(not to me, at least)

I wonder if it would not be better to leave the struct stuff alone, and to
"dimension"
the left hand side - something like ip(4) and utc(12) ? or ip*4, or whatever...

- Hendrik





More information about the Python-list mailing list