Exception as the primary error handling mechanism?
tjreedy at udel.edu
Wed Jan 6 21:49:37 CET 2010
On 1/6/2010 1:20 PM, Lie Ryan wrote:
> Python decided that the default behavior should be raising exception and
> sentinel have to use the dict.get() method. Simple and clear. The other
> possible behavior (i.e. slicing returns a sentinel while dict.get()
> raises an exception) is arguably just as simple and just as clear; but
> python doesn't do it that way. Why? Because it's part of what makes
> python Python.
The altermatives are not quite equivalent. The current way lets one
specify the sentinel whereas the alternative does not. There is hardly
any reason to specify the exception.
More information about the Python-list