Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107917 > unrolled thread
| Started by | Stephen Hansen <me@ixokai.io> |
|---|---|
| First post | 2016-04-30 10:11 -0700 |
| Last post | 2016-04-30 10:11 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Not x.islower() has different output than x.isupper() in list output... Stephen Hansen <me@ixokai.io> - 2016-04-30 10:11 -0700
| From | Stephen Hansen <me@ixokai.io> |
|---|---|
| Date | 2016-04-30 10:11 -0700 |
| Subject | Re: Not x.islower() has different output than x.isupper() in list output... |
| Message-ID | <mailman.264.1462036312.32212.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web