>> ... > That works, but if d is large, it won't be very efficient because it has > to generate a large list. It is not large. But I'm using Python 2.6 , not Python 3. I did not get this error again in the last two days. I'll post a new reply if I encounter it again. (It happened just a few times out of many thousand program invocations)