Open nickstanisha opened 7 years ago
@meowklaski Feel free to develop and make pull requests against the no_inheritance
branch. I've already added the minimum level of functionality to pass all of the tests, but I'm not satisfied with it yet because it doesn't fully satisfy point 2 above.
Once the no_inheritance
branch is ready, I'll do a final assessment of whether or not the additional code complexity is worth avoiding the headache in the code sample above.
Because of
NestedDict
's behavior when indexing tuples, the following situation could arise for a user of this projectIn response to this dilemma, I could either
isinstance(obj, NestedDict)
self._dict
object instead of subclassingdict
Using approach 2, the following conditions would have to be satisfied 1)
isinstance(obj, dict) == False
2) Attributes not found inNestedDict
will default to attributes in the internalself._dict
(effectively replicating the current class inheritance)getattr(NestedDict, attr)
should never retrieve the default attrs thatNestedDict
gets by virtue of being a Python object (e.g.__eq__
,__contains__
, etc.). The available attributes should only reflect what is hard-coded innesteddict.py
and what's present indir(dict())
3)import json; json.dumps(nesteddict)
still works (nice to have) 4)dict(nesteddict)
andNestedDict(dict)
still work