In article <mailman.174.1283114875.29448.python-l...@python.org>, MRAB <pyt...@mrabarnett.plus.com> wrote:
> On 29/08/2010 21:34, Roy Smith wrote: > > In article<8dunm7fv5...@mid.individual.net>, > > Gregory Ewing<greg.ew...@canterbury.ac.nz> 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 (http://bugs.python.org/msg94026). > > > > 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('>') > > How is that better than: > > print 'a'.isalpha() > print 'A'.isalpha() > print '1'.isalpha() > print '>'.isalpha() Think of my post as an implemention of is_reader_humour_impaired(). -- http://mail.python.org/mailman/listinfo/python-list