Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107887
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Not x.islower() has different output than x.isupper() in list output... |
| Date | Sat, 30 Apr 2016 12:10:50 +1000 |
| Lines | 60 |
| Message-ID | <mailman.244.1461982253.32212.python-list@python.org> (permalink) |
| References | <572407AE.1070703@icloud.com> <1461979797.3824480.593944273.0B8D8DF3@webmail.messagingengine.com> <57241097.7020801@icloud.com> <CAPTjJmrgtnpPSfdCqa6fyNT0FwY3jckqwr8Vqq4MZ8JCZ5V5cg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de em8VRgW7lxgQYaBVAboVDg7ACcCTVuo47AOoeb5rsTAA== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'character,': 0.07; 'cc:addr:python-list': 0.09; 'categories.': 0.09; 'situation.': 0.09; 'bug': 0.10; 'def': 0.13; '2016': 0.16; 'cased': 0.16; 'character:': 0.16; 'discussion:': 0.16; 'footnote': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lower,': 0.16; 'lowercase': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Not': 0.16; 'uppercase': 0.16; 'wrote:': 0.16; 'string': 0.17; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'stephen': 0.22; 'am,': 0.23; 'sat,': 0.23; 'thus': 0.24; 'header:In-Reply-To:1': 0.24; 'subject:list': 0.26; 'least': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:u 20': 0.28; 'character': 0.29; 'classes': 0.30; 'run': 0.33; 'url:python': 0.33; '"")': 0.33; 'received:google.com': 0.35; 'false': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'url:library': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:209': 0.38; 'url:3': 0.60; '30,': 0.63; 'chrisa': 0.84; 'to:none': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-transfer-encoding; bh=7FZdvhmrgybbYKYXsB+F2Kv+dpk9ehXZngdfycc3JxQ=; b=bJzpqK0nkuHm1fi/dMSo2EA6zGzG+UXorIMG1UDB3du7R0HpKnQBCT+nmO4E0uE9rh Sh+s5+jPDjmoquRL4z8fzpH12jB9xJeOWvUGF8ANHM5Z/cxDWUJYhY0iYW+RuKApJmfM A6koEIMusHbrgWUKER2G3PKpv/eLIIKK7r5XBYQ82CRAXgyBqzA3gveSMgZ+FvNjxwDL 1c13EO9kX/ml4/ghO/WTEiS9rh1H9qb162DUOECAmrp/Vpt4twVej+PEERTBPj9zIFxW 689lOUI6qlit5nc2IzSA78KgwUUVdoi+cFjf/IZuu9xR3Niq5L995OR1d+r+LnRjnYzI h3Jw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-transfer-encoding; bh=7FZdvhmrgybbYKYXsB+F2Kv+dpk9ehXZngdfycc3JxQ=; b=ReWsj1b5Gj+iMVe1gww2OnbNKM9BNdP9H9HalG7gR8jYd3PjrJ5UxhK5qDUOMVUfqT lzdoJBn3kgB8XbopzGPBXRU6b7jAFR5bWm/qloHqeoXcCpFkUr+mQ9/Natbb83SSnPDM pUBcjsahwWc9pzqcu1yC9VYXArRNS0lZ94mzrADohc7im5qlmypj24xzRwEZaxp3YHUe Rlz857QOnaemGELyEUP0kSzEB/RD+I6k8ejuE1aZvuhIqendiCxE4crfPZzBNRFb5rYK Asy6QkpouxY7w3QfnBbHBC5dPMLEPVG/vt+42osWJxBooW6HdzdxaeX+xFAVgD6hhDVS 3DfQ== |
| X-Gm-Message-State | AOPr4FW+kbjcU196Sl8Aq+7Y+gG9WBcT5ToXQ+R9b4E1bWN+/dkPignoMmnycgkqevkr0UKXpE8t89lm8LVoYQ== |
| X-Received | by 10.107.169.13 with SMTP id s13mr26513812ioe.19.1461982250057; Fri, 29 Apr 2016 19:10:50 -0700 (PDT) |
| In-Reply-To | <57241097.7020801@icloud.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAPTjJmrgtnpPSfdCqa6fyNT0FwY3jckqwr8Vqq4MZ8JCZ5V5cg@mail.gmail.com> |
| X-Mailman-Original-References | <572407AE.1070703@icloud.com> <1461979797.3824480.593944273.0B8D8DF3@webmail.messagingengine.com> <57241097.7020801@icloud.com> |
| Xref | csiph.com comp.lang.python:107887 |
Show key headers only | View raw
On Sat, Apr 30, 2016 at 11:55 AM, Christopher Reimer
<christopher_reimer@icloud.com> wrote:
> On 4/29/2016 6:29 PM, Stephen Hansen wrote:
>>
>> If isupper/islower were perfect opposites of each-other, there'd be no
>> need for both. But since characters can be upper, lower, or *neither*, you
>> run into this situation.
>
>
> Based upon the official documentation, I was expecting perfect opposites.
>
> str.islower(): "Return true if all cased characters [4] in the string are
> lowercase and there is at least one cased character, false otherwise."
>
> https://docs.python.org/3/library/stdtypes.html?highlight=islower#str.islower
>
> str.isupper(): "Return true if all cased characters [4] in the string are
> uppercase and there is at least one cased character, false otherwise."
>
> https://docs.python.org/3/library/stdtypes.html?highlight=isupper#str.isupper
>
> Here's the footnote that may or not be relevant to this discussion: "[4]
> Cased characters are those with general category property being one of “Lu”
> (Letter, uppercase), “Ll” (Letter, lowercase), or “Lt” (Letter, titlecase)."
>
> A bug in the docs?
>>> def case(ch):
... return (
... ("Lower " if ch.islower() else "") +
... ("Upper " if ch.isupper() else "") +
... unicodedata.category(ch)
... )
Both functions require that there be at least one cased character:
>>> case("@")
'Po'
And then each one requires a specific character class:
>>> case("a")
'Lower Ll'
>>> case("A")
'Upper Lu'
Other classes don't count:
>>> case("\u01C5")
'Lt'
There are three categories of "cased characters". Both functions check
for exactly one of those categories. Thus they are not opposites.
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Not x.islower() has different output than x.isupper() in list output... Chris Angelico <rosuav@gmail.com> - 2016-04-30 12:10 +1000
csiph-web