Best way to quit a python programme?

Charlie

I feel like an idiot asking this but is doing quit() the best way to terminate a python programme? Or is there a better way that could gradually stop all while True loops ect instead of just instantly stopping it all? Once again, I feel like an idiot asking this but I'm just curious.

user8177336

I don't know why you don't want to use quit() but you can use this:

import sys
sys.exit()

Or this:

raise SystemExit(0)

To halt a while loop you can use the break statement. For example:

while True:
    if True:
        do something  #pseudocode
    else:
        break

The break statement will immediately halt the while loop as soon as the else statement is read by python

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Best way to develop a programme without using reload

From Dev

Is there a clean way to quit evim?

From Dev

Best way to validate a name in Python

From Dev

best way for python to interface with MySQL

From Dev

Best way to "overload" function in python?

From Dev

Best way to multiprocessing python on windows

From Dev

Best way to validate a name in Python

From Dev

Best way to call a method - Python

From Dev

How to quit the interpreter in python?

From Dev

python quit function not working

From Dev

best way to run python generator cleanup code

From Dev

Best way to initialize a static list in a Python module

From Java

Best way to convert string to bytes in Python 3?

From Dev

Best way to deal with giant number of combinations python

From Dev

simple and best way of list manipulation in python

From Dev

best way to implement Apriori in python pandas

From Dev

Python best way to assume a value from dictionary?

From Dev

Best way to convert Pandas dataframe to json in python

From Dev

Python Best Way to construct Dictionary from Inputs

From Dev

Best way to identify some string in Python

From Dev

Best way to write "try elsetry" in python?

From Dev

Python. Best way to "zip" char and list

From Dev

What is the best way to insert python datetime in rethinkdb?

From Dev

Best and/or fastest way to create lists in python

From Dev

What is the best way to alias method names in python?

From Dev

What is the best way to store data in Python?

From Dev

Best way to call executable and get output in python

From Dev

Best way of using google translation by Python

From Dev

Best way to get python and meteor talking

Related Related

HotTag

Archive