[python] Python - A keyboard command to stop infinite loop?

Possible Duplicate:
Why can't I handle a KeyboardInterrupt in python?

I was playing around with some Python code and created an infinite loop:

y = 0
x = -4

itersLeft = x
while(itersLeft<0):
    y = y + x
    itersLeft = itersLeft - 1
    print "y = ",y, "itersLeft = ", itersLeft

print y

Is there a keyboard shortcut that would allow me to stop the looping - allowing me to fix the loop and then restart it?

I've tried Ctrl+C and didn't have any luck. If it helps I'm using a Windows 7 environment.

Thanks.

EDIT


I should have also mentioned that I'm using Aptana Studio 3 and attempted to run the Ctrl+C command within that. It doesn't work there - but trying it within the regular console works fine. I'm assuming it must be because of the Aptana environment.

The answer is


Ctrl+C is what you need. If it didn't work, hit it harder. :-) Of course, you can also just close the shell window.

Edit: You didn't mention the circumstances. As a last resort, you could write a batch file that contains taskkill /im python.exe, and put it on your desktop, Start menu, etc. and run it when you need to kill a runaway script. Of course, it will kill all Python processes, so be careful.


Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to command-line

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Flutter command not found Angular - ng: command not found how to run python files in windows command prompt? How to run .NET Core console app from the command line Copy Paste in Bash on Ubuntu on Windows How to find which version of TensorFlow is installed in my system? How to install JQ on Mac by command-line? Python not working in the command line of git bash Run function in script from command line (Node JS)

Examples related to keyboard-shortcuts

Collapse all methods in Visual Studio Code Is there a keyboard shortcut (hotkey) to open Terminal in macOS? Jupyter/IPython Notebooks: Shortcut for "run all"? Any way (or shortcut) to auto import the classes in IntelliJ IDEA like in Eclipse? How do I duplicate a line or selection within Visual Studio Code? How do I search for files in Visual Studio Code? OS X Terminal shortcut: Jump to beginning/end of line window.close() doesn't work - Scripts may close only the windows that were opened by it Comment shortcut Android Studio Column/Vertical selection with Keyboard in SublimeText 3

Examples related to aptana

Cannot install Aptana Studio 3.6 on Windows Python - A keyboard command to stop infinite loop? How Connect to remote host from Aptana Studio 3 Keyboard shortcut to "untab" (move a block of code to the left) in eclipse / aptana?

Examples related to infinite-loop

how do I create an infinite loop in JavaScript break statement in "if else" - java Endless loop in C/C++ How to run the Python program forever? How to get out of while loop in java with Scanner method "hasNext" as condition? Python - A keyboard command to stop infinite loop? How to create an infinite loop in Windows batch file? Which is the correct C# infinite loop, for (;;) or while (true)?