Fredrik Lundh wrote:
> Michael Yanowitz wrote:
>
> > What would be the best way to split the following line (Python doesn't like
> > me to split it up between the comma-separated parameters):
> >
> >    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 =
> > struct.unpack("!H4BH20BHI", strMessage)
>
>     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 :-)

Cheers,
John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to