Newbie question: How do I add elements to **kwargs in a function?

alex goretoy aleksandr.goretoy at gmail.com
Mon Mar 16 22:59:39 EDT 2009


I think you may need to do something like this in your code, this is what I
will be doing here shortly too

class peanutsdict(dict):
    __slots__ = ['defaultZZz']
    def __init__(self,default=None):
        dict.__init(self)
        self.default = default

    def __getitem__(self,key):
        if key in self:
            return dict.__getitem__(self,key)
        else:

            return self.default

    def get(self, key, *args):
        if not args:
            args = (self.default,)
        return dict.get(self, key, *args)

    def merge(self, other):
        for key in other:
            if key not in self:
                self[key] = other[key]

-Alex Goretoy
http://www.goretoy.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090316/5e883fff/attachment.html>


More information about the Python-list mailing list