C's isprint() concept?

Aahz Maruch aahz at netcom.com
Mon Aug 16 12:07:59 EDT 1999


In article <000201bee78f$6bbf6ec0$f22d2399 at tim>,
Tim Peters <tim_one at email.msn.com> wrote:
>[Aahz Maruch]
>>
>> Oh, sure.  What isn't clear from the way you write this is whether
>> a run of multiple non-printable characters should be replace with
>> a single space.  Here's a regex that I created recently as part of
>> some code to detect binary documents:
>>
>>    # Everything that isn't CR/LF or 7-bit normal characters
>>    reBinary = re.compile ( r'[^\r\n\x20-\x7F]' )
>
>Take a look at string.translate.

Ah.  Interesting.  I'm using re.sub because we're still on 1.5.1, but
we're supposed to move to 1.5.2 Real Soon Now.  How does
string.translate compare with the speed of re.findall?  (I'm only
interested in the number of matches; I don't intend to *do* anything
with the matches.)
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>      http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6  (if you want to know, do some research)




More information about the Python-list mailing list