On Tue, Apr 12, 2011 at 10:46 AM, Chris Angelico <ros...@gmail.com> wrote:
> def fac(n):
>    return cache[n] or (cache[n]=1 if n<=1 else fac(n-1)*n)

Hmm. The function-call version of dictionary assignment IS legal in an
expression, but it's getting stupid...

def fac(n):
    return cache.get(n) or (cache.__setitem__(n,1 if n<=1 else
fac(n-1)*n) or cache[n])

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

Reply via email to