Not x.islower() has different output than x.isupper() in list output...

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Tue May 3 10:42:28 EDT 2016


Chris Angelico writes:

> On Tue, May 3, 2016 at 9:25 PM, Jussi Piitulainen wrote:
>> Chris Angelico writes:
>>
>>> This assumes, of course, that there is a function swapcase which can
>>> return a string with case inverted. I'm not sure such a function
>>> exists.
>>
>>    str.swapcase("foO")
>>    'FOo'
>
> I suppose for this discussion it doesn't matter if it's imperfect.

Not sure. I may have misunderstood what this discussion is about - I
thought you had forgotten that Python has this function :)

>>>> "\N{ANGSTROM SIGN}".swapcase().swapcase() == "\N{ANGSTROM SIGN}"
> False
>>>> "\N{LATIN SMALL LETTER SHARP S}".swapcase().swapcase()
> 'ss'
>
> But drawing the analogy with the negation of real numbers implies
> something that doesn't exist.

I missed the relevance of that analogy.

Ceterum censeo, the only suggested use for .swapcase I've ever heard of
is encryption.



More information about the Python-list mailing list