def str_width(s): """Return the width of the string. Takes the width of East Asian characters into account """ return sum([2 if unicodedata.east_asian_width(c) == 'W' else 1 for c in s])