3. Exceptions
Simply put exceptions are error condtions which disrupt the normal
flow of the program
Python allows for a simple and elegant way to handle exceptions
>>> 0/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
Python Standard Exceptions
http://www.tutorialspoint.com/python/standard_exceptions.htm
7. >>> try:
... 10/0
... except ZeroDivisionError:
... print 'Divided by Zero'
...
Divided by Zero
>>>
8. >>> try:
... 10/0
... except Exception as err:
... print err
...
integer division or modulo by zero
>>> try:
... print name
... except Exception as err:
... print err
...
name 'name' is not defined
>>>
9. This work is licensed under the Creative Commons
Attribution-NoDerivs 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/
Copyright 2013 Mohammad reza Kamalifard.
All rights reserved.