[Python-ideas] Deprecating rarely used str methods

Andrew Barnert abarnert at yahoo.com
Mon Aug 12 09:27:51 CEST 2013


Sorry about the incomplete message. Retrying...

On Aug 11, 2013, at 23:54, Benjamin Peterson <benjamin at python.org> wrote:

> Andrew Barnert <abarnert at ...> writes:
> 
>> 
>> On Aug 11, 2013, at 23:10, Benjamin Peterson <benjamin at ...> wrote:
>> 
>>> Andrew Barnert <abarnert <at> ...> writes:
>>> 
>>>> 
>>>> On Aug 11, 2013, at 20:32, Benjamin Peterson <benjamin <at> python.org>
> wrote:
>>>> 
>>>>> Serhiy Storchaka <storchaka <at> ...> writes:
>>>>> 
>>>>>> str.swapcase() is just not needed.
>>>>> 
>>>>> I would quite love to get rid of this method, since it's basically useless
>>>>> and wrong on non-ASCII strings.
>>>> 
>>>> No it isn't.
>>> 
>>> I realize it "handles" non-ASCII characters, but I claim there is no
>>> sensical behavior.
>> 
>> So you want Python to not follow Unicode in general, or just in case
> mapping, or just in this one function
>> (leaving upper, lower, etc. alone)?
>> 
>> Out of curiosity, what language do you use that has no sensible behavior?
> Most scripts either have sensible
>> case rules, or just don't have cases (so the function is an obvious
> no-op). I know some people think Unicode
>> chose the _wrong_ rule for their script (e.g., the Turkish i mentioned
> earlier--even if it is what most
>> Turkish computer users wanted, there are purists who insist it should work
> properly, or that Turkish
>> dotted i and dotless I should be separate characters from their Latin
> equivalents). But that's not the
>> same as saying there _are_ no good rules for their script.
> 
> In the precense of things like title case, "swapping" case isn't always an
> operation that can make sense.

There aren't any title case characters. Title casing turns each character into one or more uppercase or lowercase characters. And swapcase will do exactly what you'd expect.

For example, 'ß'.title() == 'Ss' and it's obvious how that should respond to swapcase. That's a silly example, but hopefully more familiar to most people than Armenian or Church Slavonic; the point is that the same applied to all characters that either turn into two characters, from ligatures like fi to characters that have no pre compose capital form.

Are there any counter examples I'm missing?


More information about the Python-ideas mailing list