| Store | Cart

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

From: Steven DAprano <ste...@pearwood.info>
Sat, 8 Aug 2009 16:02:42 +1000
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

Recent Messages in this Thread
Jeff McAninch Aug 05, 2009 10:22 pm
Raymond Hettinger Aug 06, 2009 12:59 am
P.J. Eby Aug 06, 2009 01:20 am
Nick Coghlan Aug 06, 2009 10:47 am
Dj Gilcrease Aug 06, 2009 11:18 am
MRAB Aug 06, 2009 11:39 am
Jeff McAninch Aug 06, 2009 02:36 pm
Dino Viehland Aug 06, 2009 09:55 pm
MRAB Aug 06, 2009 11:33 pm
Dino Viehland Aug 07, 2009 12:01 am
MRAB Aug 07, 2009 12:22 am
Jeff McAninch Aug 07, 2009 10:14 am
MRAB Aug 07, 2009 11:03 am
Dj Gilcrease Aug 10, 2009 02:29 pm
Jeff McAninch Aug 06, 2009 02:11 am
Antoine Pitrou Aug 06, 2009 11:32 am
Xavier Morel Aug 06, 2009 10:25 am
Russell E. Owen Aug 06, 2009 07:55 pm
MRAB Aug 07, 2009 12:36 am
Kristján Valur Jónsson Aug 07, 2009 10:22 am
ilya Aug 07, 2009 11:06 am
Michael Foord Aug 07, 2009 11:22 am
Alex Martelli Aug 07, 2009 02:55 pm
Steven DAprano Aug 08, 2009 06:02 am
Xavier Morel Aug 08, 2009 08:17 am
Stephen J. Turnbull Aug 08, 2009 01:19 pm
Alexander Kozlovsky Aug 14, 2009 10:41 pm
Steven DAprano Aug 10, 2009 11:45 pm
Messages in this thread