diff options
| author | Ian Bertolacci <ian.bertolacci@gmail.com> | 2015-10-02 10:15:08 -0600 | 
|---|---|---|
| committer | Ian Bertolacci <ian.bertolacci@gmail.com> | 2015-10-02 10:15:08 -0600 | 
| commit | 53790a00980f0ab58efeea5a20c97366daeca401 (patch) | |
| tree | 60cced8d7b62becacd31b6fb56d9a7c41f1de809 /python3.html.markdown | |
| parent | 938720074b8b18a9ada93fb8a040b9ca1a813747 (diff) | |
| parent | d5b5b19ca909b573d0b0623604f1ff9369ab04ff (diff) | |
Merge branch 'master' of github.com:adambard/learnxinyminutes-docs
Diffstat (limited to 'python3.html.markdown')
| -rw-r--r-- | python3.html.markdown | 7 | 
1 files changed, 7 insertions, 0 deletions
| diff --git a/python3.html.markdown b/python3.html.markdown index 9d965fb1..b3acb122 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -374,6 +374,13 @@ except (TypeError, NameError):      pass    # Multiple exceptions can be handled together, if required.  else:   # Optional clause to the try/except block. Must follow all except blocks      print("All good!")   # Runs only if the code in try raises no exceptions +finally: #  Execute under all circumstances +    print("We can clean up resources here") + 		  +# Instead of try/finally to cleanup resources you can use a with statement +with open("myfile.txt") as f: +    for line in f: +        print(line)  # Python offers a fundamental abstraction called the Iterable.  # An iterable is an object that can be treated as a sequence. | 
