def __setitem__(self, key, item): """Automatically wraps lists and tuples in a TAG_List, and wraps strings and unicodes in a TAG_String.""" if isinstance(item, (list, tuple)): item = TAG_List(item) elif isinstance(item, basestring): item = TAG_String(item) item.name = key self.check_value(item) # remove any items already named "key". if not self.ALLOW_DUPLICATE_KEYS: self._value = filter(lambda x: x.name != key, self._value) self._value.append(item)
def __setitem__(self, key, item): '''Automatically wraps lists and tuples in a TAG_List, and wraps strings and unicodes in a TAG_String.''' if isinstance(item, (list, tuple)): item = TAG_List(item) elif isinstance(item, str): item = TAG_String(item) item.name = key self.check_value(item) # remove any items already named 'key'. if not self.ALLOW_DUPLICATE_KEYS: self._value = [x for x in self._value if x.name != key] self._value.append(item)