Jeff Schwab wrote: > What's the best way to generate a sequence of characters in Python? I'm > looking for something like this Perl code: 'a' .. 'z' .
>>> import re >>> def char_set(a_z, all_chars="".join(map(chr, range(256)))): ... return re.compile("[%s]" % a_z).findall(all_chars) ... >>> for c in char_set("a-f0-9"): print c, ... 0 1 2 3 4 5 6 7 8 9 a b c d e f >>> for c in char_set("\s"): print repr(c), ... '\t' '\n' '\x0b' '\x0c' '\r' ' ' Peter -- http://mail.python.org/mailman/listinfo/python-list