On Mon, Oct 28, 2019 at 10:20 AM Andrew Barnert via Python-ideas
<python-ideas@python.org> wrote:
>
> And meanwhile, if you want to change the language to turn raise into an 
> expression, why not just turn it into an expression with the same syntax, 
> just like with yield somewhere around 2.4? Then all existing code that raises 
> exceptions continues to work; only code that relies on the grammar or AST 
> breaks (and that’s explicitly allowed to break between versions).
>

When yield was turned into an expression, it was to allow it to have a value:

def coro():
    value = yield "Start"
    print("I got value:", value)
    yield "End"

x = coro()
print(next(x))
print(x.send("Hello"))

But a raise expression doesn't really make sense in that way - it
can't possibly have any value. It would be possible to use a raise
expression in a lambda function or an if/else expression, but other
than that, there wouldn't be much to gain.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/W646EG5DZHAUIZOBOIPIGUFC5Z3AZI4P/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to