> I'd also love to see string constants implemented some day too
> (like str.whitespace and str.ascii_letters).

You mean like the "string" module provides? :)

 >>> import string
 >>> print '\n'.join(["%s -> %s" % (s, repr(eval('string.%s' % 
s))) for s in dir(string) if isinstance(eval('string.%s' % s), 
basestring) and not s.startswith('_')])

ascii_letters -> 
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase -> 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase -> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits -> '0123456789'
hexdigits -> '0123456789abcdefABCDEF'
letters -> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
lowercase -> 'abcdefghijklmnopqrstuvwxyz'
octdigits -> '01234567'
printable -> 
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$
%&\'()*+,-./:;<=>[EMAIL PROTECTED]|}~ \t\n\r\x0b\x0c'
punctuation -> '!"#$%&\'()*+,-./:;<=>[EMAIL PROTECTED]|}~'
uppercase -> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace -> '\t\n\x0b\x0c\r '
 >>> string.lowercase
'abcdefghijklmnopqrstuvwxyz'

(you mentioned liking list comprehensions, so that ugly hack of a 
  one-liner extracts all the string properties of the "string" 
module that don't begin with an underscore)

-tkc




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to