[Tutor] clean text
denis.spir at free.fr
Tue May 19 13:08:42 CEST 2009
Le Tue, 19 May 2009 11:36:17 +0200,
spir <denis.spir at free.fr> s'exprima ainsi:
> This is a follow the post on performance issues.
> Using a profiler, I realized that inside error message creation, most of
> the time was spent in a tool func used to clean up source text output. The
> issue is that when the source text holds control chars such as \n, then the
> error message is hardly readible. MY solution is to replace such chars with
> their repr():
> def _cleanRepr(text):
> ''' text with control chars replaced by repr() equivalent '''
> result = ""
> for char in text:
> n = ord(char)
> if (n < 32) or (n > 126 and n < 160):
> char = repr(char)[1:-1]
> result += char
> return result
''' text with control chars replaced by repr() equivalent '''
chars = 
for char in text:
n = ord(char)
if (n < 32) or (n > 126 and n < 160):
char = repr(char)[1:-1]
But what else can I do?
la vita e estrany
More information about the Tutor