Skip to content

Instantly share code, notes, and snippets.

@cfobel
Created November 29, 2016 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfobel/de6e84b5d266bf2e47f6385935eaf8c6 to your computer and use it in GitHub Desktop.
Save cfobel/de6e84b5d266bf2e47f6385935eaf8c6 to your computer and use it in GitHub Desktop.
# See also [here][1].
#
# [1]: http://robot-framework.readthedocs.io/en/latest/_modules/robot/utils/dotdict.html
class DotOrderedDict(OrderedDict):
def __getattr__(self, attr):
try:
result = super(DotOrderedDict, self).__getattribute__(attr)
return result
except AttributeError:
if attr == '_OrderedDict__root':
raise
return self.get(attr, None)
def __setattr__(self, attr, value):
if attr.startswith('_'):
super(DotOrderedDict, self).__setattr__(attr, value)
else:
self.__setitem__(attr, value)
__delattr__ = OrderedDict.__delitem__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment