Denis, 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 repr() 5. Have result = list(), then replace result += char with result.append( char ) 6. Return ''.join( result ) Does this help? Malcolm _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor