On 9/28/07, James <[EMAIL PROTECTED]> wrote: > > > # doesn't work > for i in len( stuff ): > os.system( stuff[ i ] ) > j = i + 1 > print stuff[ j ] > > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: 'int' object is not iterable > > What precisely causes this error? I come from a C background, and > while and for loops can be molded to do precisely the same thing; it > doesn't seem like this is the case in this scenario.
You don't want to iterate through the length of the object (stuff), you want to iterate through the object itself. for i, j in stuff: os.system(i) print j and stuff would look like: stuff = [("cat /etc/passwd", "viewed /etc/passwd")] insert the pairs in tuples, rather than a list. cheers Josh
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor