List comprehension confusion...

Lulu of the Lotus-Eaters mertz at gnosis.cx
Sun Feb 2 03:27:32 EST 2003


Peter Hansen <peter at engcorp.com> wrote previously:
|>   result = map(lambda t: t.some_field, data)
|I find map very readable as well... but not lambdas.  :-)

I actually kinda agree.  Most people dread lambdas because of what they
are (the semantics).  Myself, I only have trouble with their spelling.

After looking at Haskell a bit (only a bit though, I'm no expert), the
notion of a function as just another object fully sunk in.  There's a
gestalt switch that needs to happen there... much like when I first
really "got" objects, rather than merely formally knew what they were.

But in Haskell, lambda is spelled "\".  Uncluttered (and suggestive of
the Greek letter that is missing from my keyboard).  While I admit the
Python "lambda t: t.some_field" is hard to read, I find:

    \t -> t somefield

to read quite easily.  So now my eyeballs just translate the Python
occurrences into Haskell syntax.

YMMV.

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