Created
September 25, 2016 08:21
-
-
Save arekbulski/8c0a6fc15cc59589b11169e547e33e72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Container(collections.OrderedDict): | |
__slots__ = ["__keys_order__","__recursion_lock__"] | |
def __getattr__(self, name): | |
try: | |
return self[name] | |
except KeyError: | |
raise AttributeError(name) | |
def __setattr__(self, name, value): | |
self[name] = value | |
def __delattr__(self, name): | |
del self[name] | |
def __call__(self, **kw): | |
""" | |
Chains adding new entries to the same container. See ctor. | |
""" | |
for k,v in kw.items(): | |
self.__setitem__(k, v) | |
return self |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment