Created
          March 23, 2016 16:18 
        
      - 
      
- 
        Save svetlyak40wt/1dd8547bfcd2048ab1ee to your computer and use it in GitHub Desktop. 
    Example of nested try/except in python
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # guess what will be at the output? | |
| class FooError(RuntimeError): | |
| pass | |
| class BarError(RuntimeError): | |
| pass | |
| def foo(): | |
| raise FooError() | |
| def bar(): | |
| raise BarError() | |
| try: | |
| foo() | |
| except FooError: | |
| try: | |
| bar() | |
| except BarError: | |
| print('bar catched') | |
| raise | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment