‘instancemethod’ object has no attribute ‘__getitem__’ with class variables

You didn’t post the full traceback, but I can take a guess:

def clockwise(self,speed):
    seq = stepper.clockwise
    self.WaitTime = (1.0 / (self.stepNum * self.coilNum)) * speed
    for pin in range(0, 4):
        xpin = self.pinarray[pin]
        if seq[self.StepCounter][pin]!=0:

You set seq equal to the method stepper.clockwise on the first line. Then a few lines later you try to index into it: seq[self.StepCounter]. But what does it mean to get the self.StepCounter-th element of a method?

Nothing, because:

'instancemethod' object has no attribute '__getitem__'

You shouldn’t use clockwise both as the name of a list and as the name of a method; only the last-executed definition will hold, so by the time you get to seq = stepper.clockwise, it’s the method, not the list.

Leave a Comment