
On Fri, Feb 27, 2009 at 1:20 PM, Guido van Rossum <guido@python.org> wrote:
On Fri, Feb 27, 2009 at 4:49 AM, Curt Hagenlocher <curt@hagenlocher.org> wrote:
That way lies madness. What distinguishes "with" from other compound statements is that it's already about resource management in the face of possible exceptions.
Still, a firm -1 from me. Once we have "try try" I'm sure people are going to clamor for "try if", "try while", "try for", even (oh horror :-) "try try". I don't think we should complicate the syntax just to save one level of indentation occasionally.
In addition to reasons outlined by Curt, "with" is unique because it's short-hand for a "try" block with a "finally" clause. Unfortunately, "with" doesn't allow for other clauses and so I often end up using both "try" and "with". Also, "try if", "try while", and "try for" wouldn't work because they already have a meaning for the "else" clause. "with" does not. -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>