t468.py 557 B

1234567891011121314151617181920212223242526272829303132
  1. class Matrix(object):
  2. """
  3. Represents a matrix
  4. """
  5. def __init__(self, matrix=None):
  6. """
  7. """
  8. #check if all rows same size
  9. self.mat = matrix
  10. #identity matrix initilization
  11. #scalar matrix multiplication
  12. def __getitem__(self, index):
  13. """
  14. """
  15. #print index
  16. return self.mat[index[0]][index[1]]
  17. def __setitem__(self, index, item):
  18. """
  19. """
  20. self.mat[index[0]][index[1]] = item
  21. trial=Matrix([[543]])
  22. trial[0,0]=100
  23. print trial[0,0]