[Python-Dev] Re: [Python-checkins] python/dist/src/Lib textwrap.py,1.18,1.19

Fredrik Lundh fredrik@pythonware.com
Wed, 11 Dec 2002 15:04:58 +0100


Greg Ward wrote:

> Weird.  What the heck is 0xa0 doing in string.whitespace?  Oh, =
waitasec,
> 0xa0 is non-breaking-space in ISO-8859-1.  But no, string.whitespace =
is
> hardcoded to the US-ASCII whitespace chars, all of which are in
> range(128) -- your locale shouldn't matter.

$ tail Lib/string.py

try:
    from strop import maketrans, lowercase, uppercase, whitespace
    letters =3D lowercase + uppercase
except ImportError:
    pass

$ tail Modules/strop.c

DL_EXPORT(void)
initstrop(void)
{
    ...

    /* Create 'whitespace' object */
    n =3D 0;
    for (c =3D 0; c < 256; c++) {
        if (isspace(c))
            buf[n++] =3D c;
    }
    s =3D PyString_FromStringAndSize(buf, n);
    if (s) {
        PyDict_SetItemString(d, "whitespace", s);
        Py_DECREF(s);
    }

 ...

</F>