title: How to get bit from bytearray in python?
body: <p>I want to get the particular bit value from bytearray. I tried and its working fine, but let me know is there any optimize way to do this.</p>
  
  <pre class="lang-py prettyprint-override"><code>in_bytes = bytearray()
  in_bytes .extend([5,10,15]) # output : bytearray(b'\x05\n\x0f')
  tk = in_bytes [0]
  bk = in_bytes [1]
  sk = in_bytes [2]
  print(tk, bk, sk) # 5 10 15
  bk = 10 &lt;&lt; 8
  sk = 15 &lt;&lt; 16
  res = sk | bk | tk
  print(res) # 985605
  
  def get_bit_value(number, bit_position):
      return (number &gt;&gt; bit_position) &amp; 1
  bit_value = get_bit_value(985605, 2)
  print(bit_value) # 
  </code></pre>
  
  <p>From this bytearray b'\x05\n\x0f', how can i get particular bit value?</p>