On Mon, Feb 24, 2014 at 6:26 AM, Thomas Wouters <tho...@python.org> wrote: >> I see a risk of interfering with in-place assignment operators, e.g. >> >> x /= y except ZeroDivisionError: 1 >> >> might not do what one could expect, because (as I assume) it would behave >> differently from >> >> x = x / y except ZeroDivisionError: 1 > > Yes. Augmented assignment is still assignment, so a statement. The only way > to parse that is as > > x /= (y except ZeroDivisionError: 1) > > and it'd be equivalent to > > x = x / (y except ZeroDivisionError: 1) > > (If the parentheses are mandatory that makes it easier to spot the > difference.) > >> >> I think that falls under the "overly broad exception handling" issue. If >> you want to include the assignment, you'll have to spell out the >> try-except >> block yourself. I find the difference in the two behaviours very >> unfortunate, though.
Thomas's analysis is correct. It's not overly broad; in fact, what you have is an overly _narrow_ exception handler, catching a ZeroDivisionError from the evaluation of y only. ChrisA _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com