A "scopeguard" for Python

Mike Kent mrmakent at gmail.com
Wed Mar 3 10:39:05 EST 2010


What's the compelling use case for this vs. a simple try/finally?
 original_dir = os.getcwd()
 try:
 os.chdir(somewhere)
 # Do other stuff
 finally:
 os.chdir(original_dir)
 # Do other cleanup


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /