code: def count_continuous_pattern(bitstream, pattern):
      
      assert isinstance(bitstream, (collections.Iterable, types.GeneratorType))
      assert isinstance(pattern, (list, tuple))
  
      window_size = len(pattern)
      count = -1
      for count, data in enumerate(iter_steps(bitstream, window_size), 1):
  #         print count, data, pattern
          if data != pattern:
              count -= 1
              break
  
      return count
docs: >>> pattern = list(bytes2bit_strings("A"))
      >>> bitstream = bytes2bit_strings("AAAXXX")
      >>> count_continuous_pattern(bitstream, pattern)
      3
  
      >>> pattern = list(bytes2bit_strings("X"))
      >>> bitstream = bytes2bit_strings("AAAXXX")
      >>> count_continuous_pattern(bitstream, pattern)
      0