On Sun, Apr 17, 2011 at 2:21 PM, Gregory Ewing
<greg.ew...@canterbury.ac.nz> wrote:
> My idiom for fetching from a cache looks like this:
>
>  def get_from_cache(x):
>    y = cache.get(x)
>    if not y:
>      y = compute_from(x)
>      cache[x] = y
>    return y
>
> which doesn't require any conditional returns.

There's not a lot of difference between conditionally returning and
conditionally executing all the code between here and the return,
except that when you string three conditional returns together by your
method, it gets three indentations.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to