def string(self, s): def printable(ch): if 32 <= ch <= 127: return six.unichr(ch) else: return Color.set(Color.lightgray, '.') return ''.join(map(printable, six.iterbytes(s)))