[Python-ideas] Deprecating rarely used str methods

Andrew Barnert abarnert at yahoo.com
Mon Aug 12 09:38:20 CEST 2013


Sorry, missed one last edit. Last one, I promise.

On Aug 12, 2013, at 0:27, Andrew Barnert <abarnert at yahoo.com> wrote:

> 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

... That don't have an compatible two-character form. For example, U+01C8 can be interpreted as Lj, which can be swapcased. However, arguably it shouldn't be, because the docs explicitly say that it converts upper to lower an vice-versa, which means Lt characters should be left alone just as numbers and punctuation. So you could argue that it's ambiguous, but you can't argue that nothing makes sense; it's just a choice between two different things that both make sense.

Otherwise...

> 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?
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas


More information about the Python-ideas mailing list