[Python-Dev] (try-except) conditional expression similar =?iso-8859-1?q?to=09?=(if-else) conditional (PEP 308)

Steven D'Aprano steve at pearwood.info
Sat Aug 8 08:02:42 CEST 2009


On Fri, 7 Aug 2009 08:22:14 pm Kristján Valur Jónsson wrote:
> 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.

Copying what other languages do is not necessarily a bad thing, but that 
would fail both "explicit is better than implicit" and "in the face of 
ambiguity, avoid the temptation to guess".

It's not immediately obvious to me why the last expression should be 
given that privileged rule. Why not the first expression?



> 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

Its been a while, but I don't think it ever confused me. Being unable to 
return multiple values, *that* confused me, but the distinction 
between "procedures are for doing something, functions are for getting 
something back" was perfectly straight-forward.

(And then Pascal went and made it slightly more confusing by adding var 
parameters, so you could get results back from a procedure and have 
side-effects in a function... oh well.)



-- 
Steven D'Aprano


More information about the Python-Dev mailing list