PEP 285: Adding a bool type
Lulu of the Lotus-Eaters
mertz at gnosis.cx
Tue Apr 9 17:29:36 EDT 2002
|Lulu of the Lotus-Eaters wrote:
|major = len([1 for f in fs if f(o)]))
Alex Martelli <aleax at aleax.it> wrote:
|I personally prefer:
|major = len(filter(None, [f(o) for f in fs]))
Why? I had thought of basically that one. But the short "if f(o)"
clause seemed to read better than the longer "filter(None..)" construct.
I don't really care one way or another about mixing filter() with
listcomps, but the few extra keystrokes in Alex' don't seem to add to
clarity.
Another option is to squeeze a reduce(operator.add...) into there. But
practically, len() seems to do everything that needs doing.
Yours, Lulu...
--
---[ to our friends at TLAs (spread the word) ]--------------------------
Echelon North Korea Nazi cracking spy smuggle Columbia fissionable Stego
White Water strategic Clinton Delta Force militia TEMPEST Libya Mossad
---[ Postmodern Enterprises <mertz at gnosis.cx> ]--------------------------
More information about the Python-list
mailing list