* Mike Kent: > What's the compelling use case for this vs. a simple try/finally? if you thought about it you would mean a simple "try/else". "finally" is always executed. which is incorrect for cleanup by the way, that's one advantage: a "with Cleanup" is difficult to get wrong, while a "try" is easy to get wrong, as you did here --- another general advantage is as for the 'with' statement generally > original_dir = os.getcwd() > try: > os.chdir(somewhere) > # Do other stuff also, the "do other stuff" can be a lot of code and also, with more than one action the try-else introduces a lot of nesting > finally: > os.chdir(original_dir) > # Do other cleanup cheers & hth., - alf
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4