[Raymond Hettinger] >>class Cache(dict): >> def __init__(self, n, *args, **kwds): >> self.n = n >> self.queue = collections.deque() >> dict.__init__(self, *args, **kwds)
[Bengt Richter] > Minor comment: There is a potential name collision problem for keyword > n=something, > so what is considered best practice to avoid that? __n or such as the n arg? I don't know what best practice is, but if you want to guarantee to avoid the name collision, you can write: def __init__(*args, **kwargs): self = args[0] self.n = args[1] self.queue = collections.deque() dict.__init__(self, *args[2:], **kwargs) It's not pretty though. ;) STeVe -- http://mail.python.org/mailman/listinfo/python-list