shorten this: if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":

Nick Craig-Wood nick at
Wed Jun 25 10:32:17 CEST 2008

Guilherme Polo <ggpolo at> wrote:
>  Let me post another one, and longer:
>  if ord(somechar) in range(ord('A'), ord('Z') + 1) + range(ord('a'),
>  ord('z') + 1):
>      ...

That is very inefficient!  Every time it is run it creates two lists
then joins them then throws the whole lot away!

Nick Craig-Wood <nick at> --

More information about the Python-list mailing list