Commits

Anonymous committed 8ee0ced

colunas() vira @property

  • Participants
  • Parent commits 41fc1be

Comments (0)

Files changed (2)

     def linha(self, n):
         return self.linhas[n]
         
+    @property
     def colunas(self):
         colunas = copy.deepcopy(self.linhas)
         for i, linha in enumerate(self.linhas):
         return colunas
         
     def coluna(self, n):
-        return self.colunas()[n]
+        return self.colunas[n]
         
     def transposta(self):
-        return Matriz(self.colunas())
+        return Matriz(self.colunas)
         

File test_matrices.py

     def teste_colunas(self):
         A = Matriz([[1, 1], 
                     [2, 2]])
-        self.assertEqual(A.colunas(), [[1, 2], [1, 2]])
+        self.assertEqual(A.colunas, [[1, 2], [1, 2]])
         self.assertEqual(A.coluna(0), [1, 2])
         self.assertEqual(A.coluna(1), [1, 2])
         
         A = Matriz([['A', 'B', 'C'], 
                     ['D', 'E', 'F'],
                     ['G', 'H', 'I']])
-        self.assertEqual(A.colunas(), [['A', 'D', 'G'], ['B', 'E', 'H'], ['C', 'F', 'I']])
+        self.assertEqual(A.colunas, [['A', 'D', 'G'], ['B', 'E', 'H'], ['C', 'F', 'I']])
         self.assertEqual(A.coluna(0), ['A', 'D', 'G'])
         self.assertEqual(A.coluna(1), ['B', 'E', 'H'])
         self.assertEqual(A.coluna(2), ['C', 'F', 'I'])