Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107917

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

From Stephen Hansen <me@ixokai.io>
Newsgroups comp.lang.python
Subject Re: Not x.islower() has different output than x.isupper() in list output...
Date 2016-04-30 10:11 -0700
Message-ID <mailman.264.1462036312.32212.python-list@python.org> (permalink)
References (1 earlier) <1461979797.3824480.593944273.0B8D8DF3@webmail.messagingengine.com> <57241097.7020801@icloud.com> <1461998604.3888861.594056577.710E696D@webmail.messagingengine.com> <5724E1CF.9060905@icloud.com> <1462036309.4005755.594329209.1106AF27@webmail.messagingengine.com>

Show all headers | View raw


On Sat, Apr 30, 2016, at 09:48 AM, Christopher Reimer wrote:
> On 4/29/2016 11:43 PM, Stephen Hansen wrote:
> > The official documentation is accurate. 
> 
> That may be true on a technical level. But the identically worded text 
> in the documentation implies otherwise. 

That's the thing -- no it doesn't. The documentation is very specific:
if all cased characters in the string are lowercase, and there's at
least one cased character.

It only seems to because you're packing a loop and test on substrings
into an operation.

   list(filter((lambda x: not x.islower()), string))

Let's unpack that. This is basically what you're doing:

    result = []
    for ch in string:
        if not ch.islower():
            result.append(ch)

You're thinking of the whole "string", but you're operating on
single-character substrings, and when " ".islower() is run, its false.
Because the two-pronged test, a) if all cased characters are lowercase
and b) there is at least one cased character. b) is failing. Ergo,
you're getting the underscores.

-- 
Stephen Hansen
  m e @ i x o k a i  . i o

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Not x.islower() has different output than x.isupper() in list output... Stephen Hansen <me@ixokai.io> - 2016-04-30 10:11 -0700

csiph-web