Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108205
| From | Christopher Reimer <christopher_reimer@icloud.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Pylint prefers list comprehension over filter... |
| Date | 2016-05-05 18:26 -0700 |
| Message-ID | <mailman.420.1462497989.32212.python-list@python.org> (permalink) |
| References | <572BF2BF.6000000@icloud.com> |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Pylint prefers list comprehension over filter... Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-05 18:26 -0700
csiph-web