Parsing of list of bits in python
<p>I have a list of 64 bits.</p>

<pre><code>['11111111', '11111111', '10001111', '11111110', '11011011', '11111111', '01011011', '10000111']
</code></pre>

<p>Here each and every bit represents a feature. If a bit is 1 then that particular feature is supported else not.</p>

<p>Is there any way were i can check the bit and just return its associated feature if it is 1.</p>

<p><code>Input : 1111111</code></p>

<p><code>Output: If all bits are one then I need to print all eight features masked in it.</code></p>

<p>You may unwrap the string in variable for each feature as:</p>

<pre><code>&gt;&gt;&gt; my_bit = '11111110'
&gt;&gt;&gt; feat_1, feat_2, feat_3, feat_4, feat_5, feat_6, feat_7, feat_8 = my_bit
&gt;&gt;&gt; print feat_1, feat_2, feat_3, feat_4, feat_5, feat_6, feat_7, feat_8
1 1 1 1 1 1 1 0
</code></pre>

<p>Now, you may check for each feature as:</p>

<pre><code>if feat_1:
     # Do something
else:
     # Do something else
</code></pre>

python python-2.7