On Tue, Jun 16, 2009 at 10:42 AM, Pradeep Gowda<prad...@btbytes.com> wrote: > On Tue, Jun 16, 2009 at 9:52 AM, Abhishek > Tiwari<tiwariabhishe...@gmail.com> wrote: >> I would like to know which method is better and why? > > Better for what purpose? > 1. speed of execution? > 2. elegance?
The list comprehension solution is slightly more approachable (many are not familiar with the zip() function. I don't use zip on the first go, if at all.) The zip solution is succinct. Also, by the virtue of being a built-in function zip() should be faster than the second approach. I wrote a script to test this hypothesis : http://dpaste.com/55994/ The zip() version is 100 times faster on average than the other solution. # avg time taken for ans1 : 0.0035585308075 # avg time taken for ans2 : 0.306885209084 (averaged over 50 runs) +PG _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers