[Python-checkins] python/dist/src/Lib/email Generator.py,1.16,1.17

Barry A. Warsaw barry@python.org
Mon, 14 Oct 2002 12:36:26 -0400


>>>>> "MAL" == M  <mal@lemburg.com> writes:

    >> + def _is8bitstring(s): + if isinstance(s, StringType): + try:
    >> + unicode(s, 'us-ascii')

    MAL> Note that 'ascii' will be faster since there are short-cuts
    MAL> in the C code which map this directly to the ASCII codec.

Ah cool, thanks for the tip.  I'll make that change.

    >> + except UnicodeError: + return True + return False +

    MAL> Since this kind of function occurs quite often in string
    MAL> related code, wouldn't be better to code it in C and
    MAL> publish it through e.g. the _codecs module ?!

Probably so, or something like it.  I'll see if I can't factor out the
tests I tend to do and make a proposal.

-Barry