On 30/07/2019 02:35, Steven D'Aprano wrote:
On Mon, Jul 29, 2019 at 03:12:21PM +0100, Rhodri James wrote:
I'm afraid I agree with Guido. I don't imagine I will use this feature very often, and I can see myself making that mistake every time.
Well, if you don't use this feature very often, you aren't really the audience for the feature and your feedback should therefore be weighted lower wink
I'll admit I was thinking much the same ;-)
I don't have a strong option one way or another on this feature, but I think we should resist the trap of thinking that every feature must be immediately and intuitively obvious to every reader.
I would actually like this feature, my problem is that it is immediately and obviously misleading. It needs tagging somehow to stop you (well, me) immediately thinking "Oh, this about exceptions in the body of the with/for." You suggested elsewhere giving the exception a source field, but that might be impossibly fine grained. I've been trying to come up with something more like this:
with something_exceptionable() as f: do_something_with(f) except with SomeException as e: handle_exception_in_setup_or_teardown(e) except SomeOtherException as e: handle_exception_in_body(e)
# Because I like this syntactic sugar too
-- Rhodri James - Kynesim Ltd