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.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to