Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108205 > unrolled thread
| Started by | Christopher Reimer <christopher_reimer@icloud.com> |
|---|---|
| First post | 2016-05-05 18:26 -0700 |
| Last post | 2016-05-05 18:26 -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.
Pylint prefers list comprehension over filter... Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-05 18:26 -0700
| From | Christopher Reimer <christopher_reimer@icloud.com> |
|---|---|
| Date | 2016-05-05 18:26 -0700 |
| Subject | Pylint prefers list comprehension over filter... |
| Message-ID | <mailman.420.1462497989.32212.python-list@python.org> |
Greetings,
Below is the code that I mentioned in an earlier thread.
string = "Whiskey Tango Foxtrot"
''.join(list(filter(str.isupper, string)))
'WTF'
That works fine and dandy. Except Pylint doesn't like it. According to
this link, list comprehensions have replaced filters and the Pylint
warning can be disabled.
http://stackoverflow.com/questions/3569134/why-doesnt-pylint-like-built-in-functions
Here's the replacement code using list comprehension:
''.join([x for x in string if x.isupper()])
Which is one is correct (Pythonic)? Or does it matter?
Thank you,
Chris R.
Back to top | Article view | comp.lang.python
csiph-web