Python Part-17(Classes and iterator in python), about __iter__ and __next__ methods in class

preview_player
Показать описание
Iterator in python
Need to implement the __iter__ and __next__ methods
for loop in python can iterate through an instance of a class with the above two methods implemented.
StopIteration exception handled by python only.
StopIteration just indicates that iteration is over and it simply need to exit gracefully and no more iterations needed.
__init__ method as usual has been implemented
Рекомендации по теме
Комментарии
Автор

This is the first time I can recall anyone explicitly explaining how these two magic methods get called. Suddenly you have filled the dark places with light. Thank you.

malikrumi
Автор

Sir please upload videos on ctype modules, data structures and algorithms using python.

abharani
Автор

can you discuss about hashing, mutable, immutable?

KrishnaManohar
Автор

Parentheses are not needed or recommended based on what I read.

amangelool
join shbcf.ru