コード例 #1
0
ファイル: test_typing.py プロジェクト: vihanb/ccobra
 def test_cannot_instantiate(self):
     with self.assertRaises(TypeError):
         Callable()
     with self.assertRaises(TypeError):
         type(Callable)()
     c = Callable[[int], str]
     with self.assertRaises(TypeError):
         c()
     with self.assertRaises(TypeError):
         type(c)()
コード例 #2
0
ファイル: matrix.py プロジェクト: sa2shun/DataScienceStudy
def make_matrix(
    num_rows: int, num_cols: int, entry_fn: Callable([int, int],
                                                     float)) -> Matrix:
    return [[entry_fn(i, j) for j in range(num_cols)] for i in range(num_lows)]