MCPcopy Index your code
hub / github.com/clips/pattern / __setitem__

Method __setitem__

pattern/db/__init__.py:1713–1724  ·  view source on GitHub ↗

Sets an item or row in the matrix. For Datasheet[i] = v, sets the row at index i to v. For Datasheet[i,j] = v, sets the value in row i and column j to v.

(self, index, value)

Source from the content-addressed store, hash-verified

1711 raise AttributeError, "'Datasheet' object has no attribute '%s'" % k
1712
1713 def __setitem__(self, index, value):
1714 """ Sets an item or row in the matrix.
1715 For Datasheet[i] = v, sets the row at index i to v.
1716 For Datasheet[i,j] = v, sets the value in row i and column j to v.
1717 """
1718 if isinstance(index, tuple):
1719 list.__getitem__(self, index[0])[index[1]] = value
1720 elif isinstance(index, int):
1721 self.pop(index)
1722 self.insert(index, value)
1723 else:
1724 raise TypeError, "Datasheet indices must be int or tuple"
1725
1726 def __getitem__(self, index):
1727 """ Returns an item, row or slice from the matrix.

Callers 4

__getitem__Method · 0.45
__setattr__Method · 0.45
sortMethod · 0.45
sortMethod · 0.45

Calls 3

insertMethod · 0.95
__getitem__Method · 0.45
popMethod · 0.45

Tested by

no test coverage detected