palindrome iteration

Roy Smith roy at
Sun Aug 29 22:34:16 CEST 2010

In article <8dunm7Fv5nU1 at>,
 Gregory Ewing <greg.ewing at> wrote:

> Steven D'Aprano wrote:
> >  I'm not entirely sure what the use-case for swapcase is.
> Obviously it's for correcting things that were typed
> in with tHE cAPS lOCK kEY oN bY mISTAKE. :-)

So it would seem (

It's also useful for when you're looking for a crypto algorithm and 
rot13 is too strong.

It also provides a handy way to write is_alpha()...

def is_alpha(c):
    return abs(ord(c) - ord(c.swapcase())) == 32

print is_alpha('a')
print is_alpha('A')
print is_alpha('1')
print is_alpha('>')

More information about the Python-list mailing list