Steven D'Aprano added the comment:
Thank you Raymond for the explanation. I didn't realise that there was a
technical reason why built-in generators had to be implemented as classes in
CPython.
Sanmitha's question was already discussed answered here:
Raymond Hettinger added the comment:
In pure python, generators are implemented as functions. In CPython, the only
way to implement them is as a class. From a user's point of view, enumerate(),
map(), zip(), and filter() are used like a functions (they doesn't have
non-dunder methods).
New submission from Sanmitha :
I was learning about enumerate(). While learning, when I used,
>>>help(enumerate)
Help on class enumerate in module builtins:
class enumerate(object)
| enumerate(iterable, start=0)
|
| Return an enumerate object.
|
| iterable
| an object supporting iteration
|
|