I have a simple function that works when I enter it in my Jython interpreter manually, but the call to len() fails when I try to run the code as a function.
def calculateChecksum(self, command):
sum = 0
for b in range(len(command)):
sum = sum + command[b-1]
mod = sum % 64
checkbyte = mod & (0xFF)
checksum = checkbyte | 0x80
where command is a jarray.array of bytes (Why am I not using the built-in array type? I ask you: Does it matter? jarray.array is working for everything else, and it clearly works on some occasions, see below)
>>> testarray
array([55, 57, 51], byte)
>>> len(testarray)
3
>>> stage.calculateChecksum(stage, testarray)
Traceback (innermost last):
File "<console>", line 1, in ?
File "....py", line 75, in calculateChecksum
AttributeError: __len__
So I think it's safe to say that this array implements len(), but I don't know why that doesn't always seem to be true. Any idea what's going on here?