Best way to split up lines - RE: About the 79 character linerecommendation
MRAB
google at mrabarnett.plus.com
Thu Dec 7 19:58:03 EST 2006
John Machin wrote:
> Roy Smith wrote:
>
> > It would be nice if struct.unpack() had a way to specify unpacking repeated
> > items as a list, ie:
> >
> > data = struct.unpack ("! H 4(B) H 2B 12(B) 6(B) H I", strMessage)
> > (top,
> > ip,
> > messageCounter,
> > ackRequired,
> > dataType,
> > utc,
> > st,
> > numberOfLables,
> > dataWord) = data
> >
> > and you'd end up with ip, utc, and st being lists.
>
> :-)
> Extension: if you used [] in the format string, the results would be
> tuples.
> :-)
>
[snip]
Isn't that the wrong way round? In Python, () enclose tuples and []
enclose lists!
More information about the Python-list
mailing list