I have a class like:
class TestClass(object):
def __init__(self, *args):
try:
## check some condition
except:
return
## Should exit class
def do_something_else(self):
...
def return_something(self):
## return something
Now I am trying to call the class like:
TestClass(arg1, arg2, ..).do_something_else()
somthing = TestClass(arg1, arg2, ..).return_something()
When I execute the first command, my conditions fails and raise an exception.
What I want is that if some exception occurs in __init__
function then do_something_method
should not be called and control flow should go to the second command.
In the second command, all conditions are met and the return_something
function should be called.
How can I achieve this?