Tweak generation of unicode_whitespace_trans -- clearer, more

efficient.  Suggested by MAL.
This commit is contained in:
Greg Ward 2002-12-11 13:54:20 +00:00
parent 32b4a1ba62
commit 0e88c9f65d
1 changed files with 3 additions and 2 deletions

View File

@ -52,8 +52,9 @@ class TextWrapper:
' ' * len(string.whitespace))
unicode_whitespace_trans = {}
for c in string.whitespace:
unicode_whitespace_trans[ord(unicode(c))] = ord(u' ')
uspace = ord(u' ')
for x in map(ord, string.whitespace):
unicode_whitespace_trans[x] = uspace
# This funky little regex is just the trick for splitting
# text up into word-wrappable chunks. E.g.