A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-May/024576.html below:

[Python-Dev] Re: String module

[Python-Dev] Re: String moduleGuido van Rossum guido@python.org
Wed, 29 May 2002 14:13:20 -0400
> Instead of making direct substitutes for the character lists, I
> propose we take advantage of the opportunity and provide them as
> mappings rather than strings.  That way, we can get O(1) behavior
> instead of O(n) behavior for code like: if c in str.printable:
> c='*'.  If someone needs to know the contents, they can run
> str.printable.keys().  Also, because the dictionary is mutable,
> someone can (at runtime) expand or contract the definitions:
> str.whitespace.append('_').

I don't like the idea of making this mutable at all.

But perhaps these should be replaced by predicates on strings?
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.)

--Guido van Rossum (home page: http://www.python.org/~guido/)




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4