control-C not responding, short example program

Peter Hansen peter at
Wed Jul 25 00:09:47 EDT 2001

"Owen F. Ransen" wrote:
> If you put this in a module and test it:
> def ForLoopTest (NumLoops) :
>     for Year in range (1,NumLoops) :
>         for Century in range (1,NumLoops) :
>             Months = Year*12
> you'll find that ForLoopTest (10000) will apparently
> halt 500Mhz Windows 98 machine. It simply does not
> respond to control-C. Is there a way of doing this
> or do I just have to live with it?

Are you running from the DOS command line? 
Are you executing the above function via a call like this?

if __name__ == '__main__':

I put these in a file and ran "python"
from the DOS prompt.  Hitting Ctrl-C after a few 
seconds produced this:

Traceback (most recent call last):
  File "", line 7, in ?
  File "", line 4, in ForLoopTest
    month = year * 12

So, it works for me.  (Win98 first release, on a 
Hitachi PC with a Pentium 233 MMX.  Nothing special.)

Peter Hansen, P.Eng.
peter at

More information about the Python-list mailing list