catching erros and exiting
Posted
by
apple pie
on Stack Overflow
See other posts from Stack Overflow
or by apple pie
Published on 2011-01-07T05:42:08Z
Indexed on
2011/01/07
5:53 UTC
Read the original article
Hit count: 176
In python, is there a way to exit a class after testing a condition, without exiting out of python?
say i have the class
class test():
def __init__(self):
self.a = 2
def create_b(self):
self.b = 3
def does_b_exist(self):
if <self.b doesnt exist>:
#terminate
self.b += 1
try/except` doesnt work since the rest of the program doesnt terminate after failing. im basically trying to catch an error, and do what python does when it shows you errors, but i cant figure out how to do it
© Stack Overflow or respective owner