On Fri, 21 Feb 2014 14:15:59 +1100 Chris Angelico <rosuav@gmail.com> wrote:
A number of functions and methods have parameters which will cause them to return a specified value instead of raising an exception. The current system is ad-hoc and inconsistent, and requires that each function be individually written to have this functionality; not all support this.
While I sympathize with the motivation, I really don't like the end result:
lst = [1, 2] value = lst[2] except IndexError: "No value"
is too much of a break from the usual stylistic conventions, and looks like several statements were stuffed on a single line. In other words, the gain in concision is counterbalanced by a loss in readability, a compromise which doesn't fit in Python's overall design principles. (compare with "with", which solves actual readability issues due to the distance between the "try" and the "finally" clause, and also promotes better resource management) So -0.5 from me. Regards Antoine.