I want to parse an integer that is unpack()ed using the struct module to a list of truth values.
My current approach is this:
>>> [bool(int(_)) for _ in ("%8s" % str(bin(235)).split("b")[1]).replace(" ","0")]
[True, True, True, False, True, False, True, True]
It does the job, but is quite horribly convoluted. Anyone have an elegant and pythonesque way of doing the same?
Please note that above is just for an example and the bitmasks are not necessarily just 8 bits long, but the solution should work for an bitmask of arbitrary length (in practice it might be ok to just work with multiples of 4)
Arithmetic done elegantly, without C-style proceduralism: