collada.util.IndexedList¶
-
class
collada.util.IndexedList(items, attrs)¶ Bases:
list- Class that combines a list and a dict into a single class
- Written by Hugh Bothwell (http://stackoverflow.com/users/33258/hugh-bothwell)
- Original source available at:
- http://stackoverflow.com/questions/5332841/python-list-dict-property-best-practice/5334686#5334686
- Modifications by Jeff Terrace
- Given an object, obj, that has a property x, this allows you to create an IndexedList like so:
- L = IndexedList([], (‘x’)) o = obj() o.x = ‘test’ L.append(o) L[0] # = o L[‘test’] # = o
-
__init__(items, attrs)¶ x.__init__(…) initializes x; see help(type(x)) for signature
Methods
__init__(items, attrs)x.__init__(…) initializes x; see help(type(x)) for signature append(obj)L.append(object) – append object to end extend(newList)L.extend(iterable) – extend list by appending elements from the iterable get(key[, default])insert(ind, new_obj)L.insert(index, object) – insert object before index pop([index])Raises IndexError if list is empty or index is out of range. remove(ind_or_obj)L.remove(value) – remove first occurrence of value. Attributes
count(value)index(value, [start, [stop]])Raises ValueError if the value is not present. reverseL.reverse() – reverse IN PLACE sortL.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1 -
append(obj)¶ L.append(object) – append object to end
-
extend(newList)¶ L.extend(iterable) – extend list by appending elements from the iterable
-
insert(ind, new_obj)¶ L.insert(index, object) – insert object before index
-
count(value) → integer -- return number of occurrences of value¶
-
index(value[, start[, stop]]) → integer -- return first index of value.¶ Raises ValueError if the value is not present.
-
pop([index]) → item -- remove and return item at index (default last).¶ Raises IndexError if list is empty or index is out of range.
-
reverse()¶ L.reverse() – reverse IN PLACE
-
sort()¶ L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1
-
remove(ind_or_obj)¶ L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.