[Python-Dev] Maintenance burden of str.swapcase

Michael Foord fuzzyman at voidspace.org.uk
Tue Sep 6 21:41:07 CEST 2011


On 6 Sep 2011, at 20:36, Steven D'Aprano wrote:
> 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?


The maintenance burden is on other implementations. Even if there is no maintenance burden for CPython having useless methods simply because  it is less effort to leave them in place creates work for new implementations wanting to be fully compatible. 

> 
> 
> [...]
>> 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.


Have you ever used str.swapcase for that purpose?

Michael


--
http://www.voidspace.org.uk/


May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing 
http://www.sqlite.org/different.html








More information about the Python-Dev mailing list