def __str__(self): s = "" for k in self: #_odict.__iter__(self): s += "('" + k + "', " + str(self[k]) + "), " if len(s) > 0: s = s[:-2] return _odict.__class__(_odict(self)).__name__ + "([" + s + "])"
def __repr__(self): s = "" for k in self.__odict__: #_odict.__iter__(self): s += "('" + k + "', " + str(self[k]) + "), " if len(s) > 0: s = s[:-2] return _odict.__class__(_odict(self)).__name__ + "([" + s + "])"
def __init__(self, data=None, lock=False, warn=True): ''' A dictionary or list of tuples of key/value pairs. If lock=True, keys cannot be reassigned without first deleting the item ''' super(ListDict, self).__setattr__('__lock__', lock) super(ListDict, self).__setattr__('__warn__', warn) if isinstance(data, dict): data = [ i for i in data.items() ] data = make_safe(data, warn) super(ListDict, self).__setattr__('__odict__', _odict(data)) if data: self.__dict__.update(data)
def __init__(self, data=None, warn=True, lock=False, interactive=True): ''' A dictionary or list of tuples of key/value pairs. If lock=True, keys cannot be reassigned without first deleting the item. If interactive=True, then expose keys as attributes. ''' super(ListDict, self).__setattr__('__lock__', lock) super(ListDict, self).__setattr__('__warn__', warn) super(ListDict, self).__setattr__('__inter__', interactive) if isinstance(data, dict): data = [i for i in data.items()] if interactive: data = make_safe(data, warn) super(ListDict, self).__setattr__('__odict__', _odict(data)) if interactive and data: self.__dict__.update(data)