> 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