[Tutor] whats the best command to end a program

w chun wescpy at gmail.com
Thu Dec 8 08:39:22 CET 2005


>         what would be the best command to end a program with.
>         i have an app that i want to start every day at 6am from cron
>         but i want it to shutdown at 4pm
>
>         i was going to check by time on every loop
>
>         if int(time.strftime(%H)) > 4:
>                 some end the program command
>         else:
>                 continue
>
> what would be best used here ?


i think using int(), strftime(), takes too much computation.  what's
wrong with just

if time.localtime()[3] >= 16:
    # do cleanup
    # raise SystemExit or import sys;sys.exit()

you don't even need the continue.

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2006,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list