Re: [BangPypers] List compression imrpovement

2013-01-09 Thread Guruprasad
Hi Vijay, On Wed, Jan 9, 2013 at 1:25 PM, vijay vnbang2...@yahoo.com wrote: i want to use only list compression to get solution like the way you see i share solutions. Basically one line solution . I think you are referring to list comprehension here. I want to know if there is any

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread Kushal Das
On Wed, Jan 9, 2013 at 1:25 PM, vijay vnbang2...@yahoo.com wrote: i want to use only list compression to get solution like the way you see i share solutions. Basically one line solution . Start reading from here. http://www.catb.org/esr/faqs/smart-questions.html Kushal --

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread Gora Mohanty
On 9 January 2013 13:25, vijay vnbang2...@yahoo.com wrote: i want to use only list compression to get solution like the way you see i share solutions. Basically one line solution . Do you mean list comprehension? Even so, it is not clear how the resulting list is to be derived from the

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread Anand Chitipothu
On Wed, Jan 9, 2013 at 1:11 PM, vijay vnbang2...@yahoo.com wrote: Hi, I want to know if there is any other better way for improving below list compression. I have to use list compression only to achieve it. say i have list a=[1, 4, 9, 12, 15, 21] expected result (4, 12), (9, 12,

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread Jeffrey Jose
On Wed, Jan 9, 2013 at 1:43 PM, Anand Chitipothu anandol...@gmail.comwrote: [[x for x in a if x%i == 0] for i in [2, 3]] oh thats smart. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread ragsagar
On Wed, Jan 9, 2013 at 1:11 PM, vijay vnbang2...@yahoo.com wrote: 2) [y for y in a if bool(y%2==0)],[y for y in a if bool(y%3==0)] You don't have to do if bool(y%2==0), just if y % 2 == 0 is enough. -- blog : ragsagar.wordpress.com mail id : python -c print '@'.join(['ragsagar','.'.join([x

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread Noufal Ibrahim
Jeffrey Jose jeffjosej...@gmail.com writes: On Wed, Jan 9, 2013 at 1:43 PM, Anand Chitipothu anandol...@gmail.comwrote: [[x for x in a if x%i == 0] for i in [2, 3]] oh thats smart. Yup. Very. [...] -- Cordially, Noufal http://nibrahim.net.in

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread L Radhakrishna Rao
First of all,it is list comprehension. Second, i don't know what elegant method you want to look, as list in itself is fast. The only thing which you can look out is TUPLE, which are immutable list. ___ BangPypers mailing list BangPypers@python.org

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread vijay
...@gmail.com To: Bangalore Python Users Group - India bangpypers@python.org Sent: Wednesday, 9 January 2013 1:31 PM Subject: Re: [BangPypers] List compression imrpovement Let me guess. You want the first tuple with elements that are divisible by 2 and second divisible by 3. Beats me still as to why

Re: [BangPypers] List compression imrpovement

2013-01-09 Thread vijay
Thanks Anand. This look good to me. From: Anand Chitipothu anandol...@gmail.com To: vijay vnbang2...@yahoo.com; Bangalore Python Users Group - India bangpypers@python.org Sent: Wednesday, 9 January 2013 1:43 PM Subject: Re: [BangPypers] List compression

[BangPypers] List compression imrpovement

2013-01-08 Thread vijay
Hi,    I want to know if there is any other better way for improving below list compression. I have to use list compression only to achieve it.    say i have list   a=[1, 4, 9, 12, 15, 21] expected result (4, 12), (9, 12, 15, 21)  few solutions are   1) [filter(None, l) for l in zip(*[(x if x

Re: [BangPypers] List compression imrpovement

2013-01-08 Thread Gora Mohanty
On 9 January 2013 13:11, vijay vnbang2...@yahoo.com wrote: Hi, I want to know if there is any other better way for improving below list compression. I have to use list compression only to achieve it. say i have list a=[1, 4, 9, 12, 15, 21] expected result (4, 12), (9, 12, 15, 21)