[Python-Dev] sWAPcASE Was: transform() and untransform() methods, and the codec registry

Eric Smith eric at trueblade.com
Fri Dec 10 00:10:38 CET 2010

On 12/9/2010 5:54 PM, Raymond Hettinger wrote:
> It would make me happy if we could agree to kill or at least mortally wound
> str.swapcase(). I did some research on what it is go for and found
> that it is a vestige of an old word processor command to handle
> the case where a user accidentally left the caps lock key turned-on.
> AFAICT using Google's code search, it has nearly zero value for
> Python scripts. It does have a cost however, the code search turned-up
> many cases where people were writing string like objects and included
> swapcase() just so they could match the built-in API.
> It's time for swapcase() to go the way of the dinosaurs.

+1, assuming the normal deprecation process.

If we're looking to reduce the number of methods on str, I wouldn't mind 
seeing center() and zfill() also go away, since they're trivially 
replaced by format().

 >>> '3'.zfill(10)
 >>> format('3', '>010')

 >>> '3'.center(10)
'    3     '
 >>> format('3', '^10')
'    3     '

 >>> '3'.center(10, '-')
 >>> format('3', '-^10')

Although I'll grant this the case for the demise of center() and zfill() 
isn't as strong as for swapcase(). It's truly useless.


More information about the Python-Dev mailing list