The else Clauses: provide a path to execute if no exceptions occur during the try block : try « Statement « Python Tutorial

Python Tutorial
1. Introduction
2. Data Type
3. Statement
4. Operator
5. String
6. Tuple
7. List
8. Dictionary
9. Collections
10. Function
11. Class
12. File
13. Buildin Function
14. Buildin Module
15. Database
16. Regular Expressions
17. Thread
18. Tkinker
19. wxPython
20. XML
21. Network
22. CGI Web
23. Windows
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorial
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Python Tutorial » Statement » try 
3. 8. 8. The else Clauses: provide a path to execute if no exceptions occur during the try block
try:
   v = intraw_input("Enter a value: "))
   print "We got some valid input!"
   x = 100 / v
except (KeyboardInterrupt):
   print "well, ok, if you don't really want to.."
except ZeroDivisionError:
   print "You can't divide by ZERO!"
except:
    print "Some other error happened here"
else:
    print "All went well, x = ", x
3. 8. try
3. 8. 1. try statement encloses pieces of code where one or more known exceptions may occur
3. 8. 2. Catching Exceptions
3. 8. 3. Catching Two Exceptions with One Block
3. 8. 4. Catching the Object
3. 8. 5. A Real Catch all
3. 8. 6. Have a block of code that is executed unless something bad happens;
3. 8. 7. try-finally Statement
3. 8. 8. The else Clauses: provide a path to execute if no exceptions occur during the try block
3. 8. 9. Catch Keyboard interrupt exception
3. 8. 10. Multiple except Clauses
3. 8. 11. Except two exceptions
3. 8. 12. Blank except Clauses
3. 8. 13. traceback object can print out information about the exception
3. 8. 14. Exception Arguments
3. 8. 15. get an exception's argument
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.