On 02/23/2014 11:26 AM, Thomas Wouters wrote: > > On Feb 23, 2014 7:52 PM, "Stefan Behnel" <stefan_ml at behnel.de <mailto:stefan_ml at behnel.de>> wrote: >> >> Chris Angelico, 21.02.2014 04:15: >> > Just as PEP 308 introduced a means of value-based conditions in an >> > expression, this system allows exception-based conditions to be used >> > as part of an expression. >> > [...] >> > This currently works:: >> > >> > lst = [1, 2, None, 3] >> > value = lst[2] or "No value" >> > >> > The proposal adds this:: >> > >> > lst = [1, 2] >> > value = lst[2] except IndexError: "No value" >> >> 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) Well, that is certainly not what I would have expected. I can also see how parentheses can help, but I still would like them optional. -- ~Ethan~
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