5

I'm fairly new to Python and have been using Wing IDE to play around with the features. One of the things that I could find while looking around was how to force terminate the Python shell when executing a command that won't terminate any time soon. An example would be:

import math
math.factorial(1000000)

I know in Visual Studio C++, the command is Ctrl+C, but what exactly is the Python equivalent?

Lie Ryan
  • 62,238
  • 13
  • 100
  • 144
William Kong
  • 53
  • 1
  • 5
  • that command is widely used. Executing your program on a unix shell for example, that command would work (I think so). If you are trying to do it in your IDE, just for seeing a screenshot I would say it's on the red stop sign – Ismael Abreu Apr 28 '12 at 04:09

2 Answers2

3

The method used to terminate execution varies between shells. For Wing IDE you use the Restart Shell item on the Options menu.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 1
    "Restart Shell" appears to completely wipe the state of the shell; in most interpreters, Ctrl+C-interruption leaves state intact as much as possible. – Maxander Nov 27 '13 at 19:43
0

This depends on your shell. For most shells, it is ctrl-C, or killing the process.

There is no way to do so from within python (unless you are spawning threads or processes) because the thread in question is stuck.

ninjagecko
  • 88,546
  • 24
  • 137
  • 145