[Python-ideas] Implied try blocks
grosser.meister.morti at gmx.net
Fri Mar 30 01:57:28 CEST 2012
On 03/26/2012 12:59 PM, anatoly techtonik wrote:
> On Sun, Mar 25, 2012 at 5:15 PM, Calvin Spealman<ironfroggy at gmail.com> wrote:
>> r = some_single_statement()
>> except TypeError:
>> print "oh no!"
>> raise OhNoException()
>> p = prepare(r)
>> print "I got", p
> -1, because.. When I reading this and encounter "except TypeError", I
> have to update the code that I've already read (the stuff in my head)
> to place it into exception handling block. That's a good anti-pattern
> for readability.
Slightly off topic:
And that's why I stopped to write "f() if g()" in Ruby and use the more verbose "if g(); f(); end"
there. At first it looks like a nice small syntax, but then it turns out to severely hurt
readability. I even found code like this once:
# quite some lines of code
# more code
end unless something.nil?
Yes, the whole block is actually conditional.
I think syntax, that requires you to update already parsed code is bad.
More information about the Python-ideas