diff --git a/src/attrdict.py b/src/attrdict.py index e11b0b5..8fb9a97 100644 --- a/src/attrdict.py +++ b/src/attrdict.py @@ -5,11 +5,25 @@ # http://code.activestate.com/recipes/473786/ # http://groups.google.com/group/comp.lang.python/browse_thread/thread/fa88bba7184d9431 +""" +Looks fine as long as nobody uses an existing method name as a dictionary key: + +py> d = AttrDict({'name':'value'}) +py> d.items() +[('name', 'value')] +py> d = AttrDict({'items': [1,2,3]}) +py> d.items() +Traceback (most recent call last): + File "", line 1, in +TypeError: 'list' object is not callable + +(I should have included a test case for this issue too). +Of course, if this doesn't matter in your application, go ahead and use it. Just be aware of the problem. +""" + + class AttrDict(dict): - """A dict whose items can also be accessed as member variables. - - A dictionary with attribute-style access. It maps attribute access to - the real dictionary. """ + """A dict whose items can also be accessed as member variables.""" def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = self