[Tutor] Error Handling in python

jitendra gupta jitu.icfai at gmail.com
Thu Jul 24 13:35:24 CEST 2014


Hi All

My shell script is not throwing any error when I am having  some error in
Python code.

~~~~~~~~ test.py ~~~~~~
def main():
    print "Test"
    #some case error need to be thrown
    raise Exception("Here is error")

if __name__ == "__main__"
    main()
~~~~~~
~~~~~~~~ second.py ~~~~~~
def main():
    print "Second function is called"


if __name__ == "__main__"
    main()
~~~~~~

~~~~~ shellTest.sh ~~~~~~~
python test.py
python second.py
~~~~~~~~~~~~~~~~~~~~~~~

In this case, I dont want to run my second.py
Even I am throwing error from my test.py, but still second.py is getting
executed, which i dont want,


Thanks & Regards
Jitendra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140724/df5a3f3c/attachment.html>


More information about the Tutor mailing list