Making things more functional in Python

Steve Holden steve at holdenweb.com
Fri Mar 4 12:41:28 EST 2005


Michael Hoffman wrote:
> Steve Holden wrote:
> 
>> return dict([(d, sample.getval(d)) for d in dset for sample in samples])
> 
> 
> That won't do what the original code does. This sets dict[d] to
> samples[-1].getval(d) instead of [sample.getval(d) for sample in samples].

My bad, I didn;t look closely enbough to see the need for the nested 
comprehensions.

regards
  Steve
-- 
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005                      http://www.pycon.org/
Steve Holden                           http://www.holdenweb.com/



More information about the Python-list mailing list