#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    81
    Rep Power
    12

    sys.exit problem


    Ok so here is my problem I have this code segment of code
    if opera =="/":
    if (temp1 == "0"):
    print "Error going to bail"
    self.error()
    return (int(temp2) // int(temp1))
    this works fine, when temp1=="0" it goes to the error function however

    def error(self):
    print "error"
    sys.exit(-1)
    also appears to be working, it prints out error, but then for whatever reason it continues to execute I get errors from code after it should have exited. Anyone have ideas why? I do have some of this code in a recursive function, does sys.exit not work with recurrsion?
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Any finally statements in your program?

    From the manual re: sys.exit() :
    "is implemented by raising the SystemExit exception, so cleanup actions specified by finally clauses of try statements are honored, and it is possible to intercept the exit attempt at an outer level. "

    Also if you have used atexit (see the manual) - the exit process can be modified.

    Grim

IMN logo majestic logo threadwatch logo seochat tools logo