[Python-Dev] (try-except) conditional expression similar to (if-else) conditional (PEP 308)

Kristján Valur Jónsson kristjan at ccpgames.com
Fri Aug 7 12:22:14 CEST 2009

Unless I am very much mistaken, this is the approach Ruby takes.
Everything is an expression.  For example, the value of a block is the value of
The last expression in the block.

I've never understood the need to have a distinction betwen statements and expressions, not when expressions can have side effects.  It's like that differentce between procedures and functions in pascal that only serves to confuse

> -----Original Message-----
> From: python-dev-bounces+kristjan=ccpgames.com at python.org
> [mailto:python-dev-bounces+kristjan=ccpgames.com at python.org] On Behalf
> Of Xavier Morel
> Sent: 6. ágúst 2009 10:25
> To: python-dev at python.org
> Subject: Re: [Python-Dev] (try-except) conditional expression similar
> to (if-else) conditional (PEP 308)

> Wouldn't it be smarter to fix the issue once and for all by looking
> into making Python's compound statements (or even all statements
> without restrictions) expressions that can return values in the first
> place? Now I don't know if it's actually possible, but if it is the
> problem becomes solved not just for try:except: (and twice so for
> if:else:) but also for while:, for: (though that one's already served
> pretty well by comprehensions) and with:.

More information about the Python-Dev mailing list