Build own iterator over enumerate

Posted on Mon, 27 Jun 2016 in Python • Tagged with python, iterators

Couple days ago one of my colleagues asked me to implement simple self-logging iterator inherited from enumerate. I tried to inherit directly from it and failed. I absolutely forgot how to use __new__ magic method. It was so embarrassing. I was in a hurry, so I promised myself to solve this puzzle. And I can tell you it is a simple task. Actually it takes 18 lines of code only.


Continue reading