shorten this: if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":

John Machin sjmachin at
Wed Jun 25 00:36:36 CEST 2008

On Jun 25, 4:32 am, cirfu <circularf... at> wrote:
> if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":
> cant i write something like:
> if char in "[A-Za-z]":

You can write that if you want to, but it's equivalent to
   if char in "zaZa]-[":
i.e. it doesn't do what you want.

This gives the same reuslt as your original code, unaffected by

if "A" <= char <= "Z" or "a" <= char <= "z":

More information about the Python-list mailing list