Re: [BangPypers] need help w.r.t itertools

2013-09-16 Thread Dhananjay Nene
On Mon, Sep 16, 2013 at 12:27 PM, Suyash Bhatt bhatt.suy...@gmail.com wrote: thanks for the response.. what if i have another list *e = [*'*my1name1is1','**my2name2is1','xyz','abc']* *and in the list d, I want only the elements which are present in e..* * Python 2.7.3 (default, Apr 10 2013,

Re: [BangPypers] need help w.r.t itertools

2013-09-16 Thread Saager Mhatre
On Sep 16, 2013 12:50 PM, Dhananjay Nene dhananjay.n...@gmail.com wrote: On Mon, Sep 16, 2013 at 12:27 PM, Suyash Bhatt bhatt.suy...@gmail.com wrote: thanks for the response.. what if i have another list *e = [*'*my1name1is1','**my2name2is1','xyz','abc']* *and in the list d, I want

[BangPypers] need help w.r.t itertools

2013-09-13 Thread Suyash Bhatt
Hi all, i need help in finding the most optimized way of making a list using itertools. Suppose I have 3 lists: *a=[‘my1’,’my2’] * ** *b=[‘name1’,’name2’]* *c=[‘is1’]* I want to iter through all and form another list with the following appended strings:

Re: [BangPypers] need help w.r.t itertools

2013-09-13 Thread Dhruv Baldawa
d = [''.join(x) for x in itertools.product(a, b, c)] -- Dhruv Baldawa (http://www.dhruvb.com) On Fri, Sep 13, 2013 at 4:53 PM, Suyash Bhatt bhatt.suy...@gmail.comwrote: Hi all, i need help in finding the most optimized way of making a list using itertools. Suppose I have 3 lists:

Re: [BangPypers] need help w.r.t itertools

2013-09-13 Thread Saager Mhatre
On Fri, Sep 13, 2013 at 5:01 PM, Dhruv Baldawa dhruvbald...@gmail.comwrote: d = [''.join(x) for x in itertools.product(a, b, c)] Actually, using itertools.imap would ensure that the elements aren't computed till necessary. So... d = itertools.imap(''.join, itertools.product(a, b, c)) - d