dynamic attributes, descriptors and first concurrency examples

This commit is contained in:
Luciano Ramalho
2015-01-17 22:40:40 -02:00
parent 0618105a47
commit dd1a53ff71
27 changed files with 1151 additions and 216 deletions

View File

@@ -40,11 +40,11 @@ class FrozenJSON:
return arg
def __init__(self, mapping):
self._data = dict(mapping)
self.__data = dict(mapping)
def __getattr__(self, name):
if hasattr(self._data, name):
return getattr(self._data, name)
if hasattr(self.__data, name):
return getattr(self.__data, name)
else:
return FrozenJSON(self._data[name]) # <4>
return FrozenJSON(self.__data[name]) # <4>
# END EXPLORE2