Question about __getattribute__/__getattr__

holger krekel pyth at
Mon Sep 30 17:45:54 EDT 2002

Joao Prado Maia wrote:
> On Mon, 30 Sep 2002, holger krekel wrote:
> > Probably you are interested in the Memoize recipe at 
> > 
> >
> > 
> That looks interesting, and it is indeed similar to what I'm trying to 
> acomplish, but on my case I want to keep each specific return value in a 
> separate cache file.
> The first Memoize class keeps every cached item in a dictionary, which it 
> may be fine for some applications, but I need it for a network server that 
> may be running for several days. It's not the best thing to keep 
> everything in memory ;)
> The second class keeps everything on the same pickled file (please let me 
> know if I'm wrong), which will be very slow after a couple hundred megs of 
> data in there.
> Anyway, I'm still going back to my original question: how do I get the 
> full list of arguments passed to a function ? This can't be that hard :)

The important lines from the above link are:

def __call__(self, *args):
        if not self.memo.has_key(args):
            self.memo[args] = self.fn(*args)
        return self.memo[args]

and 'args' is a tuple of arguments.  
'args[0]' would give you the first argument, for example.  



More information about the Python-list mailing list