List comprehension confusion...

Lulu of the Lotus-Eaters mertz at gnosis.cx
Sat Feb 1 23:24:07 EST 2003


Andrew Dalke <adalke at mindspring.com> wrote previously:
|get the "some_field" attribute of all elements in a list
|results = [term.some_field for term in data]

Just to throw flame on the fire, I am one of the odd people who find map
quite readable too:

  result = map(lambda t: t.some_field, data)

Yours, Lulu...

--
    _/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: Postmodern Enterprises _/_/_/
   _/_/    ~~~~~~~~~~~~~~~~~~~~[mertz at gnosis.cx]~~~~~~~~~~~~~~~~~~~~~  _/_/
  _/_/  The opinions expressed here must be those of my employer...   _/_/
 _/_/_/_/_/_/_/_/_/_/ Surely you don't think that *I* believe them!  _/_/






More information about the Python-list mailing list