On 02/23/2014 11:26 AM, Thomas Wouters wrote:
On Feb 23, 2014 7:52 PM, "Stefan Behnel" <stefan...@behnel.de
<mailto:stefan...@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~
_______________________________________________
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