[Python-Dev] other "magic strings" issues

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Sun Nov 9 17:54:41 EST 2003

> From: python-dev-bounces+tdelaney=avaya.com at python.org
> I guess the tests should be faster, yes, but I would still 
> want _iterables_ for ascii_*  and digits.
> One issue with allowing "if char in string.letters:" is that 
> these days this will not raise if the alleged 'char' is more
> than one character -- it will give True for (e.g.) 'ab', False
> for (e.g.) 'foobar', since it tests _substrings_.

# inside string.py or equivalent ...

import sets

ascii_letters = sets.Set(ascii_letters)

Hmm - we'd have the iterability, individual characters and speed, but lose iterating in order. I'm sure there's things out there that rely on iterating over ascii_letters in order ... ;)

Tim Delaney

More information about the Python-Dev mailing list