[issue45154] Enumerate() function or class?

2021-09-09 Thread Steven D'Aprano
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:

[issue45154] Enumerate() function or class?

2021-09-09 Thread Raymond Hettinger
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).

[issue45154] Enumerate() function or class?

2021-09-09 Thread Sanmitha
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 | |