Why am I getting a TypeError when looping?
Posted
by Lee Crabtree
on Stack Overflow
See other posts from Stack Overflow
or by Lee Crabtree
Published on 2010-04-21T18:31:00Z
Indexed on
2010/04/21
18:33 UTC
Read the original article
Hit count: 187
python
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?
© Stack Overflow or respective owner