[Python-Dev] Re: A cute new way to get an infinite loop (original) (raw)

Tim Peters tim.peters at gmail.com
Fri Sep 24 06:14:56 CEST 2004


[Terry Reedy]

Very similar to this old way (2.2 and I presume before):

Been there forever, yes.

>>> l=[1] >>> for i in l: l.append(i) ... Traceback (most recent call last): File "", line 1, in ? KeyboardInterrupt >>> len(l) 1623613

but admittedly a bit more baroque ;-) So, are things like this a programming bug, interpreter bug, or language definition bug? or just a 'gotcha'?

They're features, provoked into revealing their dark sides by pilot error. It's not an accident that I posted my note right after checking in a new test, in test_long.py, containing:

   cases.extend([-x for x in cases])

I will not admit that it didn't always contain the square brackets. And if I won't admit that, I sure won't admit that I initially feared hairy new code for mixed float-vs-long comparison contained an infinite loop .

never-getting-an-infinite-loop-is-a-symptom-of-not-trying-hard-enough-ly y'rs - tim



More information about the Python-Dev mailing list