Best way to split up lines - RE: About the 79 character linerecommendation
John Roth
JohnRoth1 at jhrothjr.com
Thu Dec 7 10:20:27 EST 2006
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
>
> </F>
Or simply put parentheses around the tuple on the left,
and use the ending parenthesis to get to the last line:
(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)
John Roth
More information about the Python-list
mailing list