On Feb 22, 1:32 pm, Robert Kern wrote:
> On 2/22/11 1:49 PM, goodman wrote:
>
> > Hi, my question is this: Is it a bad idea to create a wrapper class
> > for a dictionary so I can add attributes?
>
> Nope. I do recommend adding a custom __repr__(), though.
>
Good point. Thanks
--
http://mail.pyt
Instead of inheriting a dict, why not composing a dict into your "model"
class, like:
class Model(object):
def __init__(self, *args, **kwargs):
self._probabilities = defaultdict(lambda: defaultdict(float))
@property
def features(self):
# insert
On 2/22/11 1:49 PM, goodman wrote:
Hi, my question is this: Is it a bad idea to create a wrapper class
for a dictionary so I can add attributes?
Nope. I do recommend adding a custom __repr__(), though.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
Hi, my question is this: Is it a bad idea to create a wrapper class
for a dictionary so I can add attributes? E.g.:
class DictWithAttrs(dict):
pass
More information:
I'm using a nested defaultdict to store a machine-learning model,
where the first key is a class, the second key is a feature,