Feature suggestion -- return if true

James Mills prologic at shortcircuit.net.au
Mon Apr 11 22:12:12 EDT 2011


On Tue, Apr 12, 2011 at 11:44 AM, Grant Edwards <invalid at invalid.invalid> wrote:
> How is that the same?
>
>  return? something()                  return something() or None
>  return? somethingelse()              return somethingelse() or None
>  log("didn't find an answer")         log("didn't find an answer")
>  raise ValueError                     raise ValueError
>
> Are you saying the two snippets above are equivalent?

def foo(n):
    x = n < 5
    if x:
        return x

is functionally equivalent to:

def foo(n):
    return n < 5

-- 
-- James Mills
--
-- "Problems are solved by method"



More information about the Python-list mailing list