control-C not responding, short example program

Peter Hansen peter at engcorp.com
Wed Jul 25 06:09:47 CEST 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__':
    ForLoopTest(10000)

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

C:\>py test.py
Traceback (most recent call last):
  File "test.py", line 7, in ?
    ForLoopTest(10000)
  File "test.py", line 4, in ForLoopTest
    month = year * 12
KeyboardInterrupt
C:\>

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 engcorp.com



More information about the Python-list mailing list