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


Groups > comp.lang.python > #108205 > unrolled thread

Pylint prefers list comprehension over filter...

Started byChristopher Reimer <christopher_reimer@icloud.com>
First post2016-05-05 18:26 -0700
Last post2016-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.


Contents

  Pylint prefers list comprehension over filter... Christopher Reimer <christopher_reimer@icloud.com> - 2016-05-05 18:26 -0700

#108205 — Pylint prefers list comprehension over filter...

FromChristopher Reimer <christopher_reimer@icloud.com>
Date2016-05-05 18:26 -0700
SubjectPylint 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web