
On Thu, Feb 26, 2009 at 7:28 PM, Bruce Frederiksen <dangyogi@gmail.com>wrote:
How about this?
I tried it, but it matches quite a few comments and strings. Try putting a "print repr(match.group(0))" in the innermost loop to debug it.
On my last response, I mentioned a suggestion to add __throw__ to context managers. But then I remembered that the __exit__ method is already given the exception information if an exception is raised. So you can already do what I was suggesting now.
I'm still curious as to how often you could share try/except cases by writing your own context managers.
Not particularly often. Much of the time, the exception handler has to clean up the mess when a file is unexpectedly unreadable or SQL explodes, and the clean-up bit is tied to the immediately surrounding code. YMMV. -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>