- 1

Can someone explain the __iter__and __next__?

28th Feb 2018, 7:48 AM
zhe
zhe - avatar
2 Answers
0
If you create your own containers for example you want to make them iterateable. To achieve that these objects have to implement a __iter__ function which will return the iterator of your object (can be the same object again) this iterator has to have the function __next__ which gets called every step of the iteration to retrieve the next element.
28th Feb 2018, 8:07 AM
Chrizzhigh
Chrizzhigh - avatar
0
thanks
28th Feb 2018, 12:03 PM
zhe
zhe - avatar