def terminal_len(value):
 if isinstance(value, bytes):
  value = value.decode('utf8', 'ignore')
 return len(value)

def terminal_len ( value ) : if isinstance ( value , bytes ) : value = value . decode ( 'utf8' , 'ignore' ) return len ( value )
returns the length of the string it would be when displayed .