Not x.islower() has different output than x.isupper() in list output...
Chris Angelico
rosuav at gmail.com
Tue May 3 06:25:17 EDT 2016
On Tue, May 3, 2016 at 8:00 PM, <pavlovevidence at gmail.com> wrote:
>
> What you should have been expecting is a symmetry. Say you have a string G. islower(G) will return a certain result. Now take every letter in G and swap the case, and call that string g. isupper(g) will always return the same result is islower(G).
>
> More succinctly, for any string x, the following is always ture:
>
> islower(x) == isupper(swapcase(x))
>
> But that is not the same thing, and does not imply, as the following identity (which it turns out is not always true, as we've seen):
>
> islower(x) == not isupper(x)
>
>
> Another example of functions that behave like this are ispositive and isnegative. The identity "ispositive(x) == isnegative(-x)" is always true. However, "ispositive(x) == not isnegative(x)" is false if x == 0.
>
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.
ChrisA
More information about the Python-list
mailing list