python generatorを使用してlistを生成
List公式ドキュメント: Lists are mutable sequences, typically used to store collections of homogeneous items (where the precise degree of similarity will vary by application). class list([iterable]) Lists may be constructed in several ways: Using a pair of square brackets to denote the empty list: [] Using square brackets, separating items with commas: [a], [a, b, c] Using a list comprehension: [x for x in iterable] Using the type constructor: list() or list(iterable)
generator自体がiteratorなので、iterableに違いありません.
eg:
generator自体がiteratorなので、iterableに違いありません.
eg:
def take (n):
for i in range(n):
yield i
l = list(take(4))
>>> l = [0,1,2,3]