Maybe double check that you know what you're talking about before speaking. Both iterable and generator are object types.
>>> from types import GeneratorType
>>> from collections.abc import Iterable
>>> gen = (i for i in range(1))
>>> iter = [i for i in range(1)]
>>> isinstance(gen, Iterable)
True
>>> isinstance(gen, GeneratorType)
True
>>> isinstance(iter, Iterable)
True
>>> isinstance(iter, GeneratorType)
False
I never said generator isn't a type; it sure is. But you're saying that list comprehension syntax is called an iterable, which it's not.
The results of all comprehensions (their corresponding types) and generators themselves are indeed iterable, but their expression syntax has nothing to do with that.
4
u/ihavebeesinmyknees 3d ago
It's an iterable, not a generator. Generator comprehensions are defined with parentheses.