[Tutor] whats the best command to end a program

Alan Gauld alan.gauld at freenet.co.uk
Tue Dec 6 22:49:36 CET 2005


> what would be the best command to end a program with.

If its Tkinter (or another GuI) there will be a quit command 
somewhere. Call that to ensure that the GUI framework gets 
tidied up properly.

For normal programs

import sys; sys.exit()

You can pass an exit code to the outdside world as 
a parameter to exit too.

or just

raise SystemExit

will work.

> i have an app that i want to start every day at 6am from cron
> but i want it to shutdown at 4pm

OK, here you probably want system.exit(n) with a proper error 
code so that cron can tell if it worked or not...

BTW strftime('%H') returns the hour in 24 hour format so you 
will want to check for 16 not 4...

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list