Delete all not allowed characters..

Zentrader zentraders at gmail.com
Thu Oct 25 18:24:04 EDT 2007


>         allowed =
> [u'+',u'0',u'1',u'2',u'3',u'4',u'5',u'6',u'7',u'8',u'9',u' ', u'Þ',
> u'þ', u'Ö', u'ö', u'Ü', u'ü', u'Ç', u'ç', u'Ý', u'ý', u'Ð', u'ð', 'A',
> 'C', 'B', 'E', 'D', 'G', 'F', 'I', 'H', 'K', 'J', 'M', 'L', 'O', 'N',
> 'Q', 'P', 'S', 'R', 'U', 'T', 'W', 'V', 'Y', 'X', 'Z', 'a', 'c', 'b',
> 'e', 'd', 'g', 'f', 'i', 'h', 'k', 'j', 'm', 'l', 'o', 'n', 'q', 'p',
> 's', 'r', 'u', 't', 'w', 'v', 'y', 'x', 'z']

Using ord() may speed things up.  If you want to include A through Z
for example, you can use
ord_chr=ord(chr)   ## convert once
if (ord_chr) > 64 and (ord_chr < 91):    (On a U.S. English system)
and won't have to check every letter in an 'include it' string or
list.  Lower case "a" through "z" would be a range also, and u'0'
through u'9' should be as well.  That would leave a few remaining
characters that may have to be searched if they are not contiguous
decimal numbers.




More information about the Python-list mailing list