[Python-Dev] Re: String module
M.-A. Lemburg
mal@lemburg.com
Wed, 29 May 2002 21:07:50 +0200
Guido van Rossum wrote:
> Most of the constants already have a predicate companion:
>
> whitespace -- isspace()
> lowercase -- islower()
> uppercase -- isupper()
> letters -- isalpha()
> digits -- isdigit()
>
> That leaves:
>
> hexdigits -- isxdigit()
> octdigits -- isodigit()
> punctuation -- ispunct()
> printable -- isprint()
>
> Perhaps we should add isalnum, iscntrl, is graph, to match <ctype.h>?
> Or perhaps not? (Maybe I'd also like to add isword(), which would be
> isalnum() or '_' -- this is the definition of \w in the re module.)
FYI, Unicode has these:
{"islower", (PyCFunction) unicode_islower, METH_NOARGS, islower__doc__},
{"isupper", (PyCFunction) unicode_isupper, METH_NOARGS, isupper__doc__},
{"istitle", (PyCFunction) unicode_istitle, METH_NOARGS, istitle__doc__},
{"isspace", (PyCFunction) unicode_isspace, METH_NOARGS, isspace__doc__},
{"isdecimal", (PyCFunction) unicode_isdecimal, METH_NOARGS, isdecimal__doc__},
{"isdigit", (PyCFunction) unicode_isdigit, METH_NOARGS, isdigit__doc__},
{"isnumeric", (PyCFunction) unicode_isnumeric, METH_NOARGS, isnumeric__doc__},
{"isalpha", (PyCFunction) unicode_isalpha, METH_NOARGS, isalpha__doc__},
{"isalnum", (PyCFunction) unicode_isalnum, METH_NOARGS, isalnum__doc__},
Note that unlike for ASCII strings, the characters all have
defined categories.
Strings miss a few of these:
{"islower", (PyCFunction)string_islower, METH_NOARGS, islower__doc__},
{"isupper", (PyCFunction)string_isupper, METH_NOARGS, isupper__doc__},
{"isspace", (PyCFunction)string_isspace, METH_NOARGS, isspace__doc__},
{"isdigit", (PyCFunction)string_isdigit, METH_NOARGS, isdigit__doc__},
{"istitle", (PyCFunction)string_istitle, METH_NOARGS, istitle__doc__},
{"isalpha", (PyCFunction)string_isalpha, METH_NOARGS, isalpha__doc__},
{"isalnum", (PyCFunction)string_isalnum, METH_NOARGS, isalnum__doc__},
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/
Meet us at EuroPython 2002: http://www.europython.org/