[Python-Dev] PEP 463: Exception-catching expressions
brett at python.org
Fri Feb 21 15:34:34 CET 2014
On Fri, Feb 21, 2014 at 8:52 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Fri, 21 Feb 2014 14:15:59 +1100
> Chris Angelico <rosuav at 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
> > lst = [1, 2]
> > value = lst 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
> (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)
While I like the general concept, I agree that it looks too much like a
crunched statement; the use of the colon is a non-starter for me. I'm sure
I'm not the only one whose brain has been trained to view a colon in Python
to mean "statement", period. This goes against that syntactic practice and
just doesn't work for me.
I'm -1 with the current syntax, but it can go into the + range if a better
syntax can be chosen.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev