[Python-Dev] Maintenance burden of str.swapcase

Steven D'Aprano steve at pearwood.info
Tue Sep 6 21:36:27 CEST 2011


Terry Reedy wrote:
> On 9/6/2011 12:58 PM, Tres Seaver wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 09/06/2011 12:59 PM, Stephen J. Turnbull wrote:
>>> Joao S. O. Bueno writes:
>>>
>>>> Removing it would mean explicitly "batteries removal".
>>>
>>> That's what we usually do with a dead battery, no?<wink />
>>
>> Normally one "replaces" dead batteries. :)
> 
> Not if it is dead and leaking because the device has been unused for years.


Can we please not make decisions about what code should be removed based 
on dodgy analogies? :)

Perhaps I missed something early on, but why are we proposing removing a 
function which (presumably) is stable and tested and works and is not 
broken? What maintenance is needed here?


[...]
> If k is lowercase, .lower() is redundant and 
> k[0].swapcase()+k[1:].lower() == k.title(). 

Not so.

 >>> k = 'aaaa bbbb'
 >>> k.title()
'Aaaa Bbbb'
 >>> k[0].swapcase()+k[1:].lower()
'Aaaa bbbb'


> If k is uppercase, previous 
> .upper() is redundant. If k is mixed case, code may have problems.

"May" have problems?


pERSONNALLY, i THINK THAT A SWAPCASE COMMAND IS ESSENTIAL FOR TEXT 
EDITOR APPLICATIONS, TO AVOID THOSE LITTLE cAPS lOCK ACCIDENTS.



-- 
Steven


More information about the Python-Dev mailing list