# File: userdict-example-1.py

import UserDict

class FancyDict(UserDict.UserDict):

    def __init__(self, data = {}, **kw):
        UserDict.UserDict.__init__(self)
        self.update(data)
        self.update(kw)

    def __add__(self, other):
        dict = FancyDict(self.data)
        dict.update(b)
        return dict

a = FancyDict(a = 1)
b = FancyDict(b = 2)

print a + b

## {'b': 2, 'a': 1}
