Possible Duplicate:
Python try-else
I'm not seeing the benefit of it, at least based on the example I just read in Dive Into Python:
try:
from EasyDialogs import AskPassword
except ImportError:
getpass = default_getpass
else:
getpass = AskPassword
(http://www.diveintopython.net/file_handling/index.html)
Why couldn't you achieve the same effect with the shorter/simpler:
try:
from EasyDialogs import AskPassword
getpass = AskPassword
except ImportError:
getpass = default_getpass
What am I missing?
getpass = AskPassword
could raise anImportError
itself?from EasyDialogs import AskPassword as getpass