I'm new to Python and have been doing work converting a few apps from Perl
to Python.  I can not figure out the comparable Python structures for
multi-variable for loop control.

Examples:

# In Perl
for($i = 0, j = 0; $i < I_MAX && $j < J_MAX; $i+=5, $j += 10)
{
   ..... do something
}

// In Java
class test {
     public static void main(String[] args){
          int i = 0;
          int j = 1;
          for(i=1, j = 0; i<11 && j < 10; i++, j++){
               System.out.println("I is: " + i);
               System.out.println("J is: " + j);
          }
     }
}


// In C
#include <stdio.h>
int main()
{
  int j = 0;
  int k = 0;

  for(j = 0, k = 0; j < 5 && k < 10; j++, k++) {
    printf("J = %d\n", j);
    printf("k = %d\n", k);
    }

  return 0;
  }

I spent a good part of yesterday looking for a way to handle this style for
loop in Python and haven't been able to find an appropriate way to handle
this control style.  We have this style for loop all over the place and not
being able to find a similar structure in Python could be a problem.  Any
pointers to a Python equivalent structure would be much appreciated

- Mark
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to