From: Gerhard Sittig Date: Sun, 1 Jul 2018 13:26:09 +0000 (+0200) Subject: common: rephrase bitpack(), use list comprehension Python idiom X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c7172e5fa77d5cd56f206c4991762ce33ef78eba;p=libsigrokdecode.git common: rephrase bitpack(), use list comprehension Python idiom --- diff --git a/decoders/common/srdhelper/mod.py b/decoders/common/srdhelper/mod.py index 3c495b4..e37345a 100644 --- a/decoders/common/srdhelper/mod.py +++ b/decoders/common/srdhelper/mod.py @@ -25,10 +25,7 @@ def bin2int(s: str): return int('0b' + s, 2) def bitpack(bits): - res = 0 - for i, b in enumerate(bits): - res |= b << i - return res + return sum([b << i for i, b in enumerate(bits)]) def bitunpack(num, minbits=0): res = []