def _change_colours(self, colour, attr, bg):
            # Change attribute first as this will reset colours when swapping
            # modes.
            if attr != self._attr:
                sys.stdout.write(
                    self._terminal.normal + self._terminal.on_color(0))
                if attr != 0:
                    sys.stdout.write(self.ATTRIBUTES[attr](self._terminal))
                self._attr = attr
                self._colour = None

            # Now swap colours if required.
            if colour != self._colour:
                sys.stdout.write(self._terminal.color(colour))
                self._colour = colour
            if bg != self._bg:
                sys.stdout.write(self._terminal.on_color(bg))
                self._bg = bg
>>> s = [b'foo']
dataset/ETHPy150Open peterbrittain/asciimatics/asciimatics/screen.py/_BlessedScreen._change_colours--crossover with--dataset/ETHPy150Open richardkiss/pycoin/pycoin/tx/script/microcode.py/do_OP_HASH160