Why am I getting a TypeError when looping?
- by Lee Crabtree
I'm working on a Python extension module, and one of my little test scripts is doing something strange, viz.:
x_max, y_max, z_max = m.size
for x in xrange(x_max):
for y in xrange(y_max):
for z in xrange(z_max):
#do my stuff
What makes no sense is that the loop gets to the end of the first 'z' iteration, then throws a TypeError, stating that "an integer is required". If I put a try...except TypeError around it and check the types of x, y, and z, they all come back as < type 'int' .
Am I missing something here?