En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop <[EMAIL PROTECTED]> escribió:
> On Apr 3, 6:33 pm, [EMAIL PROTECTED] wrote: >> I saw example of memoize function...here is snippet >> >> def memoize(fn, slot): >> def memoized_fn(obj, *args): >> if hasattr(obj, slot): >> return getattr(obj, slot) >> else: >> val = fn(obj, *args) >> setattr(obj, slot, val) >> return val >> return memoized_fn >> >> and I am really clueless, about what it does. I know in general we try >> to keep computed values for future usage. But I am having hard-time >> visualizing it. >> What is obj here? and what does *args means? > > *args is Python's syntax for variadic functions. In case the strange name gives you nothing, see section 4.7 in the Tutorial [1] For a much simpler implementation, see this FAQ entry [2] [1] http://docs.python.org/tut/node6.html#SECTION006700000000000000000 [2] http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list