Comment on Exceptions (2003)parentComments−untothebreach13yIt seems to be a pattern in Python APIs to allow the caller to decide if a given function call should throw an exception when an error occurs. For example, a = some_dict['nonexistent_key'] would raise a KeyError, while a = some_dict.get('nonexistent_key', 'DEFAULT') would return 'DEFAULT' instead.
Comments
It seems to be a pattern in Python APIs to allow the caller to decide if a given function call should throw an exception when an error occurs. For example,
would raise a KeyError, while would return 'DEFAULT' instead.