def once(func):
def wrapper(*args, **kwargs):<EOL><INDENT>if not hasattr(func, '<STR_LIT>'):<EOL><INDENT>func.always_returns = func(*args, **kwargs)<EOL><DEDENT>return func.always_returns<EOL><DEDENT>return functools.wraps(func)(wrapper)<EOL>
Decorate func so it's only ever called the first time.

This decorator can ensure that an expensive or non-idempotent function
will not be expensive on subsequent calls and is idempotent.

>>> func = once(lambda a: a+3)
>>> func(3)
6
>>> func(9)
6
>>> func('12')
6