def __getitem__( self, key ):

    if isinstance( key, slice ):

      start_addr = int(key.start)
      num_bytes = int(key.start) - int(key.stop)
      bits = Bits( 8*num_bytes )

      for i in range(num_bytes):
        bits[i*8:i*8+8] = \
          struct.unpack_from("<B",buffer(self.mem,start_addr+i,1))[0]

      return bits

    else:
      idx = int(key)
      return Bits( 8, struct.unpack_from("<B",buffer(self.mem,idx,1))[0] )

  #-----------------------------------------------------------------------
  # eq
  #-----------------------------------------------------------------------
dataset/ETHPy150Open cornell-brg/pymtl/pclib/fl/Bytes.py/Bytes.__getitem__/swapped operands of `-`