[Tutor] clean text

python at bdurham.com python at bdurham.com
Tue May 19 14:57:05 CEST 2009


Untested idea: 

1. Fill a dict with pre-calculated repr() values for chars you want to
replace (replaceDict)

2. Create a set() of chars that you want to replace (replaceSet).

3. Replace if (n < 32) ... test with if char in replaceSet

4. Lookup the replacement via replaceDict[ char ] vs. calculating via

5. Have result = list(), then replace result += char with result.append(
char )

6. Return ''.join( result )

Does this help?


More information about the Tutor mailing list