[Python-ideas] Deprecating rarely used str methods

Andrew Barnert abarnert at yahoo.com
Mon Aug 12 08:00:58 CEST 2013


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.

Most people who say that are mixing up bytes.swapcase with str.swapcase (or talking about Python 2). The bytes method obviously only handles ASCII because bytes objects don't know what encoding they're in (or even whether they're text in the first place) so nothing else would make sense. But the str method handles non-ASCII cases just as well as the rest of Python. For example, 'éåüñ'.swapcase() == 'ÉÅÜÑ'.

Of course Unicode case mapping isn't perfect, because it's contextless, and because it doesn't handle language-specific tailoring, and because it has all the usual compromises (like Turkish dotless i). But I doubt you're suggesting that Python reject Unicode.

Of course your other reason for rejecting it--that it's useless--I think most people agree with.



More information about the Python-ideas mailing list