Exception as the primary error handling mechanism?

Terry Reedy tjreedy at udel.edu
Wed Jan 6 15:49:37 EST 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[1].

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.

tjr




More information about the Python-list mailing list