I think the for i in range() is more readable (Maybe because I'm coming from a c-style syntax language background) - but what would the benefits of using enumerate be (other that being more . . . pythonesque?)
On 5/5/07, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Fri, 4 May 2007 19:26:17 -0700, [EMAIL PROTECTED] (Alex Martelli) > declaimed the following in comp.lang.python: > > > for i in range(n): > > for j in range(i+1, n): > > print a[i], a[j] > > > Ah, but wouldn't the cleaner Python be something like > > > >>> a = [1, 2, 3, 4, 5, 3, 6] #just to confuse matters > >>> for pos, val in enumerate(a): > ... for v2 in a[pos+1:]: > ... print val, v2 > ... > 1 2 > 1 3 > 1 4 > 1 5 > 1 3 > 1 6 > 2 3 > 2 4 > 2 5 > 2 3 > 2 6 > 3 4 > 3 5 > 3 3 > 3 6 > 4 5 > 4 3 > 4 6 > 5 3 > 5 6 > 3 6 > >>> > -- > Wulfraed Dennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list