On Mon, Feb 24, 2014 at 6:26 AM, Thomas Wouters <thomas at 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4