About 48,500 results
Open links in new tab
  1. python - How do I terminate a script? - Stack Overflow

    Sep 16, 2008 · A simple way to terminate a Python script early is to use the built-in quit() function. There is no need to import any library, and it is efficient and simple. Example: #do stuff if this == that: quit()

  2. What is the best way to exit a function (which has no return value) …

    return None or return can be used to exit out of a function or program, both does the same thing; quit() function can be used, although use of this function is discouraged for making real world applications and should be used only in interpreter.

  3. Python exit commands - why so many and when should each be …

    Nov 3, 2013 · After all, one of the most likely things a newbie will try to exit Python is typing in quit. Nevertheless, quit should not be used in production code. This is because it only works if the site module is loaded. Instead, this function should only be used in the interpreter. exit() is an alias for quit (or vice-versa). They exist together simply ...

  4. How to properly quit a program in python - Stack Overflow

    Oct 23, 2012 · Now Quit will be whatever the user typed in, so let's check for "Q" instead of True: if Quit == "Q": Instead of sys.exit(0), you can probably just end your while look with break or just return if you're in a function. Also, I don't recommend the name "Quit" for a variable that just stores user input, since it will end up confusing.

  5. python - How to stop a function - Stack Overflow

    A simple return statement will 'stop' or return the function; in precise terms, it 'returns' function execution to the point at which the function was called - the function is terminated without further action. That means you could have a number of places throughout your function where it might return. Like this:

  6. How do I abort the execution of a Python script? [duplicate]

    Jan 26, 2010 · done = True if done: # quit/stop/exit else: # do other stuff Essentially, I am looking for something that behaves equivalently to the 'return' keyword in the body of a function which allows the flow of the code to exit the function and not execute the remaining code.

  7. difference between quit and exit in python - Stack Overflow

    Oct 10, 2013 · 1) When I use help() and type() function for each one, it says that both are object of class Quitter, which is defined in the module site. 2) When I use id() to check the addresses of each one, it returns different addresses i.e. these are two different objects of …

  8. python - Proper way to quit/exit a PyQt program - Stack Overflow

    Calling QCoreApplication.quit() is the same as calling QCoreApplication.exit(0). To quote from the qt docs: After this function has been called, the application leaves the main event loop and returns from the call to exec(). The exec() function returns returnCode. If the event loop is not running, this function does nothing. [emphasis added]

  9. How to quit Python function, throwing error statement without …

    Perhaps out of ignorance (I see many beginners just doing except:), perhaps because they really want to catch all exception out of some misguided sense of "reliability" (sometimes seen in intermediate programmers), perhaps because catching (almost) all exceptions really is the correct thing to do at this point, e.g. you're running arbitrary code (e.g. a …

  10. How to stop/terminate a python script from running?

    Nov 5, 2013 · You can also do it if you use the exit() function in your code. More ideally, you can do sys.exit(). sys.exit() which might terminate Python even if you are running things in parallel through the multiprocessing package. Note: In order to …

  11. Some results have been removed
Refresh