[Python-Dev] default of returning None hurts performance? (original) (raw)

Xavier Morel catch-all at masklinn.net
Tue Sep 1 15:12:34 CEST 2009


On 1 Sep 2009, at 02:01 , Greg Ewing wrote:

I don't think the unpredictability that would introduce would be a good idea. I fail to grasp the unpredictability of "the last expression evaluated
in the body of a function is its return value".

It couldn't work in Python because statements aren't expressions,
therefore I think

 def foo():
     if cond:
         3
     else:
         4

would break (given if:else: doesn't return a value, the function
couldn't have a return value), but in languages where everything is an
expression (where if:else: does return a value) there's nothing
unpredictable about it.



More information about the Python-Dev mailing list