Re: Moving to functional programming

2008-07-11 Thread craig75
On Jul 11, 3:36 am, [EMAIL PROTECTED] wrote: > James Fassett: > > > # the first Pythonic attempt using comprehensions > > result_list = [x[0] for x in tuple_list] > > > # the final functional way > > [result_list, _] = zip(*tuple_list) > > > I really like how Python allows me to do what I feel is t

Re: Idiomatic Python to convert list to dict

2008-07-10 Thread craig75
On Jul 10, 10:06 am, James Fassett <[EMAIL PROTECTED]> wrote: > Hi all, > > Simple question really on a best practice. I want to avoid adding > duplicates to a list. > > my_list = ['a', 'b', 'c', 'd', 'e'] > dup_map = {} > for item in my_list: >     dup_map[item] = True > > # ... sometime later > >