En Sat, 05 May 2007 05:15:32 -0300, kaens <[EMAIL PROTECTED]>
escribió:
> 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?)
If y
Dustan <[EMAIL PROTECTED]> wrote:
> On May 5, 3:15 am, kaens <[EMAIL PROTECTED]> wrote:
> > 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 . . .
>
Dustan <[EMAIL PROTECTED]> writes:
> > 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?)
>
> It doesn't create a whole new li
On May 5, 3:15 am, kaens <[EMAIL PROTECTED]> wrote:
> 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?)
It doesn't create a whole n
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 -
In <[EMAIL PROTECTED]>, prad wrote:
> On Friday 04 May 2007 18:40:53 Tommy Grav wrote:
>> Can anyone help me with the right approach for this
>> in python?
>
> for each in a:
> for item in a[a.index(each)+1:]:
> print each,item
>
> will produce
>
> 1 2
> 1 3
> 1 4
> 1 5
> 2 3
> 2 4
prad wrote:
> On Friday 04 May 2007 18:40:53 Tommy Grav wrote:
>> Can anyone help me with the right approach for this
>> in python?
>
> for each in a:
> for item in a[a.index(each)+1:]:
> print each,item
>
> will produce
>
> 1 2
> 1 3
> 1 4
> 1 5
> 2 3
> 2 4
> 2 5
> 3 4
> 3 5
> 4 5
Tommy Grav <[EMAIL PROTECTED]> writes:
> In C this would be equivalent to:
> for(i = 0; i < n; i++) {
> for(j=i+1; j < n; j++) {
> print a[i], a[j]
for i in xrange(n):
for j in xrange(i+1, n):
print a[i], a[j]
--
http://mail.python.org/mailman/listinfo/python-list
Tommy Grav wrote:
> I have a list:
>
>a = [1., 2., 3., 4., 5.]
>
> I want to loop over a and then
> loop over the elements in a
> that is to the right of the current
> element of the first loop
>
> In C this would be equivalent to:
>
> for(i = 0; i < n; i++) {
> for(j=i+1; j < n; j++)
On Friday 04 May 2007 18:40:53 Tommy Grav wrote:
> Can anyone help me with the right approach for this
> in python?
for each in a:
for item in a[a.index(each)+1:]:
print each,item
will produce
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
a.index(each) gives the index of the each value i
Tommy Grav <[EMAIL PROTECTED]> wrote:
> I have a list:
>
>a = [1., 2., 3., 4., 5.]
>
> I want to loop over a and then
> loop over the elements in a
> that is to the right of the current
> element of the first loop
>
> In C this would be equivalent to:
>
> for(i = 0; i < n; i++) {
> for
11 matches
Mail list logo